This file contains 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 singleLetterCount(word, letter) { | |
var count = 0; | |
for(var i = 0; i < word.length; i++) { | |
if(word[i].toUpperCase() == letter.toUpperCase()) { | |
count++; | |
} | |
} | |
return count; | |
} |
This file contains 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 arrayManipulation(arr, command, location, value) { | |
if(command == "remove" && location =="end") { | |
return arr.pop(); | |
} else if (command =="remove" && location =="beginning") { | |
return arr.shift(); | |
} else if(command ="add" && location =="beginning") { | |
arr.unshift(value) | |
return arr |
This file contains 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 findall(a, x) { | |
var results = [], // The array of indexes we'll return | |
len = a.length, // The length of the array to be searched | |
pos = 0; // The position to search from | |
while(pos < len) { // While more elements to search... | |
pos = a.indexOf(x, pos); // Search | |
if (pos === -1) break; // If nothing found, we're done. | |
results.push(pos); // Otherwise, store index in array | |
pos = pos + 1; // And start next search at next element | |
} |
This file contains 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 hummus = function(factor) { | |
const ingredient = function(amount, unit, name) { | |
let ingredientAmount = amount * factor; | |
if (ingredientAmount > 1) { | |
unit += "s"; | |
} | |
console.log(`${ingredientAmount} ${unit} ${name}`); | |
}; | |
ingredient(1, "can", "chickpeas"); | |
ingredient(0.25, "cup", "tahini"); |
This file contains 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
mongod --dbpath "C:\Program Files\MongoDB\data\db" |
This file contains 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
m.sort(function (a, b) { | |
if (a === b) { | |
return 0; | |
} | |
if (typeof a === typeof b) { | |
return a < b ? -1 : 1; | |
} | |
return typeof a < typeof b ? -1 : 1; | |
}); |
This file contains 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 sumPrimes(num) { | |
var count = [] | |
for(var j = 0; j < num; j++) { | |
if(isPrime(j)) { | |
count.push(j) | |
console.log(count) | |
} | |
This file contains 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
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules && yarn install && npm start -- --reset-cache |
This file contains 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
var input = 222323.34343; | |
function formatSum(sum) { | |
if(Number.isInteger(sum)) { | |
return sum | |
} | |
var beforeDot = /[^.]*/.exec(sum)[0] | |
var afterDot = /(?<=\.).*/.exec(sum)[0] | |
return beforeDot + ',' + afterDot |
This file contains 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 findSum = (arr, val) => { | |
for (let i = 0; i < arr.length; i++) { | |
for (let j = 0; j < arr.length; j++) { | |
if (i !== j && arr[i] + arr[j] === val) { | |
return true; | |
}; | |
}; | |
}; | |
return false; | |
}; |
OlderNewer