This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const user = { name: 'David', age: 30, city: 'New York'}; | |
const copy = {...user}; | |
console.log(copy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const user = { name: 'David', age: 30, city: 'New York'}; | |
const copy = Object.assign({}, user); | |
console.log(copy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const user = { name: 'David', age: 30, city: 'New York' }; | |
const updateUser = function(updates) { | |
return { ...user, ...updates }; | |
}; | |
const updatedUser = updateUser({ age: 34, city: 'Boston'}); | |
console.log(updatedUser); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git grep -n $'require([\'"]express[\'"]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git grep $'\.http_mode' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"name":"Joker", | |
"release_date":"2019-10-02", | |
"director": "Todd Phillips", | |
"image": "https://upload.wikimedia.org/wikipedia/en/e/e1/Joker_%282019_film%29_poster.jpg", | |
"description": "During the 1980s, a failed stand-up comedian is driven insane and turns to a life of crime and chaos in Gotham City while becoming an infamous psychopathic crime figure." | |
}, | |
{ | |
"name":"Frozen 2", | |
"release_date":"2019-11-20", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateEmail = email => /^[^@ ]+@[^@ ]+\.[^@ \.]+$/.test(email); | |
const isValidEmail = function(value) { | |
if (validateEmail(value)) { | |
return true; | |
} else { | |
return "Please enter a valid email address"; | |
} | |
} | |
let isValid = isValidEmail('abc@gmail.com'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateEmail = email => /^[^@ ]+@[^@ ]+\.[^@ \.]+$/.test(email); | |
const isValidEmail = value => validateEmail(value) || 'Please enter a valid email address.'; | |
let isValid = isValidEmail('abc@gmail.com'); | |
console.log(isValid); // true | |
isValid = isValidEmail('abc@@gmail.com'); | |
console.log(isValid); // Please enter a valid email address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isNotEmpty = function(fieldName) { | |
return function(fieldValue) { | |
if (fieldValue.trim().length > 0) { | |
return true; | |
} else { | |
return fieldName[0].toUpperCase() + fieldName.slice(1) + " is required."; | |
} | |
}; | |
}; |