This file contains hidden or 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 arr = ["M", "A", "S", "A", "U", "T", "T"] | |
//Remove the first element | |
arr.shift(); // returns "M" | |
console.log(arr) // --> [ 'A', 'S', 'A', 'U', 'T', 'T' ] |
This file contains hidden or 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 arr = ["M", "A", "S", "A", "U", "T", "T"] | |
//Remove the last element | |
arr.pop(); // returns "T" | |
console.log(arr) // --> [ 'M', A', 'S', 'A', 'U', 'T' ] |
This file contains hidden or 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
function shuffleArray(arr) { | |
for (let i = arr.length - 1; i > 0; i--) { | |
const j = Math.floor(Math.random() * (i + 1)); | |
[arr[i], arr[j]] = [arr[j], arr[i]]; | |
} | |
return arr; | |
} | |
let arr = [8,6,7,5,3,0,9]; |
This file contains hidden or 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 start = new Date(); | |
setTimeout(()=> { | |
console.log((new Date() - start) / 1000 + " seconds have passed"); // --> 5 seconds have passed | |
},5000); |
This file contains hidden or 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
function roundUp(num, prec) { | |
prec = Math.pow(10, prec); | |
return Math.ceil(num * prec) / prec; | |
} | |
function roundDown(num, prec) { | |
prec = Math.pow(10, prec); | |
return Math.floor(num * prec) / prec; | |
} | |
// Built in Math function |
This file contains hidden or 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
// Remove all whitespace | |
function delWS1(str) { | |
return str.replace(/\s/g,""); | |
} | |
// Remove trailing and leading whitepsace | |
function delWS2(str) { | |
return str.replace(/^[ ]+|[ ]+$/g,''); | |
} |
This file contains hidden or 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
{ | |
"editor.accessibilitySupport": "off", | |
"editor.mouseWheelZoom": true, | |
"workbench.iconTheme": "material-icon-theme", | |
"editor.detectIndentation": false, | |
"explorer.confirmDelete": false, | |
"editor.wordWrap": "on", | |
"editor.minimap.enabled": false, | |
"terminal.integrated.rendererType": "dom", | |
"workbench.colorTheme": "One Dark Pro Vivid", |
This file contains hidden or 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
function roundUp(num, prec) { | |
prec = Math.pow(10, prec); | |
return Math.ceil(num * prec) / prec; | |
} | |
function roundDown(num, prec) { | |
prec = Math.pow(10, prec); | |
return Math.floor(num * prec) / prec; | |
} | |
// Built in Math function |
This file contains hidden or 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
{ | |
"total" : 0, | |
"lastUpdated" : "Thu, 07 Nov 2019 22:55:15 GMT" | |
} |
This file contains hidden or 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
x | y | |
---|---|---|
20 | 20 | |
25 | 25 | |
30 | 20 | |
20 | 5 | |
30 | 5 |