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 generateIntegers(m, n) { | |
| let arr = [] | |
| let init = m | |
| let length = (n - m) + 1 | |
| while(arr.length < length){ | |
| arr.push(init) | |
| init = init + 1 | |
| } | |
| return arr |
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 removeDuplicatetElevations(arr){ | |
| console.log("NON FILTERED === ", arr) | |
| const filteredArr = arr.reduce((acc, current) => { | |
| const x = acc.find(item => item['height'] === current['height']); | |
| if (!x) { | |
| return acc.concat([current]); | |
| } else { | |
| return acc; | |
| } | |
| }, []); |
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 splitArrToSmallerChunks(bigArr){ | |
| let arrOfArr = [] | |
| while(bigArr.length){ | |
| arrOfArr.push(bigArr.splice(0,50)) | |
| } | |
| return arrOfArr | |
| } |
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 requestAJAX(url, callback) { | |
| var xhr = new XMLHttpRequest(); | |
| xhr.onreadystatechange = function () { | |
| if (xhr.readyState == 4 && xhr.status == 200) { | |
| callback(JSON.parse(xhr.responseText)) | |
| } | |
| } | |
| xhr.open('GET', url, true) | |
| xhr.send() | |
| } |
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 factorial(num){ | |
| let total = 1; | |
| for(let i=1;i<=num;i++){ | |
| total *= i; | |
| } | |
| return total; | |
| } |
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 randInBetweenNumbers(min, max) { | |
| return Math.floor(Math.random() * (max - min + 1) + min); | |
| } |
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 middleInBetweenNumnbers(min, max) { | |
| return Math.floor((max+min)/2); | |
| } |
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 add(arr){ | |
| let total = 0; | |
| arr.forEach(function(num){ | |
| console.log(num); | |
| total += Number.parseInt(num); | |
| }); | |
| console.log(total); | |
| return total; | |
| } |
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 isEven(i){ | |
| function subtract(){ | |
| console.log(i - 2); | |
| return i - 2; | |
| } | |
| if(i===0){ return true; } | |
| if(i === 1){ return false; } | |
| if(i <=0){ | |
| return 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 isEven(i){ | |
| if(i % 2 === 0){ | |
| console.log(true); | |
| } else{ | |
| console.log(false); | |
| } | |
| }isEven(-1); |
NewerOlder