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
| { | |
| "React Component - Export default function": { | |
| "prefix": "rfcd", | |
| "body": [ | |
| "export default function ${1:ComponentName}() {", | |
| " return (", | |
| " <>", | |
| " $0", | |
| " </>", | |
| " );", |
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
| const chunk = (array, size) => { | |
| let result = []; | |
| while (array.length > 0) { | |
| result.push(array.splice(0, size)); | |
| } | |
| return result; | |
| }; |
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
| // 1st solution | |
| function reverseInt(n) { | |
| var str = n | |
| .toString() | |
| .split('') | |
| .reverse() | |
| .join(''); | |
| if (n < 0) return parseInt('-' + str); | |
| if (n >= 0) return parseInt(str); |
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
| // 1st solution | |
| const palindrome = (str) => (str === str.split('').reverse().join('')); | |
| //second solution - inefficient solution - 2x the work | |
| const palindrome = (str) => { | |
| return str.split('').every( (char, index) => { | |
| return char === str[str.length - i - 1]; | |
| } | |
| } |
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
| //1st try | |
| function reverse(str) { | |
| var newStr = []; | |
| for (var i = str.length - 1; i >= 0; i--) { | |
| newStr.push(str[i]); | |
| } | |
| return newStr.join(''); | |
| } | |
| //2nd attempt - 1 liner |
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
| for (var i = 1; i <= 100; i++) { | |
| if (i % 3 === 0 && i % 5 === 0) { | |
| console.log('fizzbuzz'); | |
| } else if (i % 5 === 0) { | |
| console.log('buzz'); | |
| } else if (i % 3 === 0) { | |
| console.log('fizz'); | |
| } else { | |
| console.log(i); | |
| } |
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 factorialize(num) { | |
| if (num < 2) return 1; | |
| return num * factorialize(num-1); | |
| } | |
| console.log(factorialize(5)); |