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 PRECISION = 0.2; // Often called a Delta | |
function isValid(time) { // Ensures 1 second has elapsed | |
const expected = 1; | |
// We only assert this : (expected - precision) <= time <= (expected + precision) | |
return (expected - PRECISION <= time) && (expected + PRECISION >= time); | |
} | |
console.log(isValid(1.105)); |
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
let x = 5; | |
let expected = 8; | |
console.log('Content of variable x is: ' + x + ', and expected is ' + expected); | |
// => Content of variable x is: 5, and expected is 8 |
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
let x = 5; | |
let expected = 8; | |
console.log(`Content of variable x is: ${x} and expected is ${expected}`); | |
// => Content of variable x is: 5, and expected is 8 |
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
let x = [1,2,3,4,5]; | |
let y = []; | |
for(let i = 0; i < x.length; i ++) | |
y[i] = x[i]*2; | |
console.log(y); | |
// => [2,4,6,8,10] |
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
let x = [1,2,3,4,5]; | |
let y = x.map ( element => element*2 ); | |
console.log(y); | |
// => [2,4,6,8,10] |
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
let x = [1,2,3,4,5]; | |
let y = []; | |
for(let i = 0; i < x.length; i++) | |
if(x[i] % 2 == 0) | |
y.push(x[i]*2); | |
else | |
continue; | |
console.log(y); |
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
let x = [1,2,3,4,5]; | |
let y = x.filter( element => element % 2 == 0).map(element => element*2); | |
console.log(y); | |
// => [4,8] |
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
var OPTIONS = { | |
'GRAYSCALE': 1, 'SEPIA': 2, 'HIGH-RES': 3, 'LOW-RES': 4 | |
}; | |
function setCameraSettings(options) { | |
if(options.includes(OPTIONS['GRAYSCALE'])) | |
console.log('GRAYSCALE activated'); | |
if(options.includes(OPTIONS['SEPIA'])) | |
console.log('SEPIA activated'); | |
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
var OPTIONS = { | |
'GRAYSCALE': 1, 'SEPIA': 2, 'HIGH-RES': 4, 'LOW-RES': 8 | |
}; | |
function setCameraSettings(options) { | |
if( options & OPTIONS['GRAYSCALE'] ) | |
console.log('GRAYSCALE activated'); | |
if( options & OPTIONS['SEPIA'] ) | |
console.log('SEPIA activated'); | |
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
// Hypothetical NLP function - ES6 includes used | |
function isTextFunEnough(text) { | |
if(text.length == 0) { | |
return false; | |
} | |
else if(text.includes('lol')) { | |
if(text.includes('angry')) | |
return false; | |
else | |
return true; |