GitHub
AdamMescher/nvte-next
GitHub
AdamMescher/nvte-next
Must-know JavaScript array methods
The some() method tests whether at least one element in the array passes the test implemented by the provided function.
| My Awesome Sketch | |
| First State | |
| some event -> Second State | |
| Second State |
| for (let i = 0; i < input.length; i++) { | |
| for (let j = 0; j < input.length; j++) { | |
| if (input[i] + input[j] === 2020) { | |
| console.log(`Output: ${input[i]} * ${input[j]} = ${input[i] * input[j]}`) | |
| break | |
| } | |
| } | |
| } |
| for (let i = 0; i < input.length; i++) { | |
| for (let j = 0; j < input.length; j++) { | |
| for (let k = 0; k < input.length; k++) { | |
| if(input[i] + input[j] + input[k] === 2020) { | |
| console.log(`Output: ${input[i] * input[j] * input[k]}`) | |
| break | |
| } | |
| } | |
| } | |
| } |
| String.prototype.count = function(char) { | |
| return (this.length - this.replace(new RegExp(char,"g"), '').length) / s1.length | |
| } | |
| input.reduce((accum, item) => { | |
| const charMin = item[0].split('-')[0] | |
| const charMax = item[0].split('-')[1] | |
| const char = item[1] | |
| const password = item[2] |
| input.reduce((accum, item) => { | |
| const pos1 = item[0].split('-')[0] - 1 | |
| const pos2 = item[0].split('-')[1] - 1 | |
| const char = item[1] | |
| const password = item[2] | |
| if( password.charAt(pos1) === char ^ password.charAt(pos2) === char) { | |
| accum++ | |
| } |
| *::before, | |
| *::after { | |
| box-sizing: border-box; | |
| } | |
| body, | |
| h1, | |
| h2, | |
| h3, | |
| h4, |