Skip to content

Instantly share code, notes, and snippets.

View jx13xx's full-sized avatar
🎯
Focusing

Jean Xavier jx13xx

🎯
Focusing
  • Dubai, United Arab Emriates
View GitHub Profile
class Employee {
constructor(name, daysWorked) {
this.name = name;
this.daysWorked = daysWorked;
}
calculatePay() {
const dailyPay = 100; // let's assume daily pay is 100
return this.daysWorked * dailyPay;
}
@jx13xx
jx13xx / app.js
Created April 1, 2022 12:45
reduce, map, filter example javascript
const scores = [50, 6, 100, 0, 10, 75, 8, 60, 90, 80, 0, 30, 110];
//Any scores that are below 10 needs to be multiplied by 10 and the new value included.
const boostSingleScores = scores.map(function (val) {
return (val < 10) ? val *10 : val;
})
//Remove any scores that are over 100.
@jx13xx
jx13xx / gist:81eb23a716e321ddd1c4025cdfd4a225
Created March 19, 2022 12:50
IIFE - Immediately Invoked Fucntion Expressions Javascript
var firstname = "MyNamew";
(function(name){
var greeting = "Inside IIFE: Hellow"
console.log(greeting + '' + name);
}(firstname))
@jx13xx
jx13xx / App.js
Created February 6, 2022 15:14
Custom Button React Component
return (
<Card>
<form>
<h2> How you rate your service with us?</h2>
<div className={'input-group'}>
<input
onChange={handleTextChange}
type={'text'}
placeholder={'Write a review'}
value={text}/>
@jx13xx
jx13xx / condtional_jsx.js
Created February 2, 2022 01:59
Conditionals in JSX
const showComments = true;
function App() {
return (
<div className='container'>
<h1>Blog Post</h1>
{showComments ? (<div className='comments'>
<h3>Comments ({comments.length})</h3>
@jx13xx
jx13xx / App.js
Created February 2, 2022 01:48
Dyanmic List in React JSX
const comments = [
{id: 1, text: 'Comment One'},
{id: 2, text: 'Comment Two'},
{id: 3, text: 'Comment Three'},
]
function App() {
return (
<div className='comments'>
<h3>Comments ({comments.length})</h3>
@jx13xx
jx13xx / EmailValidationCheck.js
Created January 26, 2022 18:15
EmailValidationCheck
let cases = {
'firstName' : 'FirstName',
'lastName' : 'LastName',
'email': '[email protected]',
'salary': 500235
}
const verifiedEmail = !!cases["email"].match(/([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/)
// OR
@jx13xx
jx13xx / Rectangle.js
Created January 26, 2022 11:44
Liskov Substitution Principle
class Rectangle extends Shape {
constructor(width, height){
super();
this.width = width;
this.height = height;
}
getArea(){
return this.width * this.height;
}
@jx13xx
jx13xx / EmailValidationCheck.js
Created January 19, 2022 08:54
Email Validation in Javascript
let cases = {
'firstName' : 'FirstName',
'lastName' : 'LastName',
'email': '[email protected]',
'salary': 500235
}
const verifiedEmail = !!cases["email"].match(/([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/)
// OR
@jx13xx
jx13xx / filter.js
Created January 18, 2022 08:44
Filtering search in array using arrow method
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
const containsE = words.filter(word => word.match(/[e]/g) );
console.log(containsE);
console.log(result);