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 openOrSenior(data){ | |
| // ... | |
| return data.map(array => array[0] >= 55 && array[1] > 7 ? 'Senior' : 'Open'); | |
| } |
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 narcissistic(value) { | |
| let array = value.toString().split(''); | |
| let count = array.length; | |
| let result = array.map((num) => Math.pow(num, count)); | |
| if(eval(result.join(',').replace(/,/g, '+')) == value) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
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 queueTime(customers, n) { | |
| let i = 0, | |
| tills = []; | |
| for(i; i < n; i++){ | |
| tills[i] = 0; | |
| } | |
| customers.forEach((min) => { | |
| tills.fill((getMin(tills)['min'] + min), getMin(tills)['index'], getMin(tills)['index'] + 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
| function solution(number){ | |
| var sum = 0; | |
| for(var i = 1;i< number; i++){ | |
| if(i % 3 == 0 || i % 5 == 0){ | |
| sum += i | |
| } | |
| } | |
| return sum; | |
| } |
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 solution(str){ | |
| var str_array = str.split(''); | |
| var result = []; | |
| str_array.forEach((value, key) => { | |
| if(key % 2 == 0) { | |
| let next = (str_array[key + 1] ? str_array[key + 1] : '_') | |
| result.push(value + next); | |
| } | |
| }); | |
| 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
| function divide(weight){ | |
| //your code here | |
| return weight > 2 && weight % 2 == 0 ? true : false; | |
| } |
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 pigIt(str){ | |
| var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/; | |
| return str.split(' ').map((word) => { | |
| if(format.test(word)) | |
| return word; | |
| let array = word.split(''); | |
| let first = array.shift(); | |
| return (array.join('') + first + 'ay'); | |
| }).join().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
| function formatDuration (sec) { | |
| if(sec == 0) | |
| return 'now'; | |
| let s = sec % 60; | |
| let m = Math.floor((sec % 3600) / 60); | |
| let h = Math.floor((sec % 86400) / 3600); | |
| let d = Math.floor((sec % 31536000) / 86400); | |
| let Y = Math.floor(sec / 31536000); | |
| let string = ''; | |
| let flag = false; |
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 permutations(string) { | |
| var arr = string.split(''), tmp = arr.slice(), heads = [], out = []; | |
| if(string.length == 1) return [string]; | |
| arr.forEach(function(v, i, arr) { | |
| if(heads.indexOf(v) == -1) { | |
| heads.push(v); | |
| tmp.splice(tmp.indexOf(v), 1); | |
| permutations(tmp.join('')).forEach(function(w) {out.push(v + w);}); | |
| tmp.push(v); | |
| } |
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
| Array.prototype.sameStructureAs = function (other) { | |
| Array.prototype.status = Array.prototype.status || true; | |
| if(this.length != other.length){ | |
| Array.prototype.status = false; | |
| return false; | |
| } | |
| for(var index = 0; index < this.length; index++) | |
| { |