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 binaryAgent(str) { | |
let newStr = str.split(" "); | |
return newStr.map(item=>{ | |
return String.fromCharCode(parseInt(item, 2)); | |
}).join(""); | |
} | |
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111"); |
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 steamrollArray(arr) { | |
let stringFormat = arr.toString().split(","); | |
return stringFormat.filter(item=>item != '').map(item=>{ | |
if(item == "[object Object]"){ | |
return {}; | |
}else{ | |
return parseInt(item) ? parseInt(item) : item; |
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 dropElements(arr, func) { | |
let newArray = []; | |
let checkedItem = []; | |
arr.map((item, index)=>{ | |
let alreadyDeleted = checkedItem.some(innerItem=>innerItem==item); | |
if(alreadyDeleted) newArray.push(arr[index]); | |
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 smallestCommons(arr) { | |
let numbers = arr.sort((a, b)=>a-b); | |
for(let i = numbers[0]; i <= numbers[1]; i++){ | |
numbers.push(i); | |
} | |
return numbers.reduce((a, b) => { | |
return lcm(a, b); | |
}); |
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 sumPrimes(num) { | |
let i,flag,j; | |
let sum = 0; | |
for(i=1; i<=num; i++) | |
{ | |
flag=0; | |
for(j=1; j<=num; j++) | |
{ | |
if(i%j==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
function sumFibs(num) { | |
let temp = 0, temp2 = 1, | |
nextTerm, sum = 0; | |
while(temp < num){ | |
nextTerm = temp + temp2; | |
temp = temp2; | |
temp2 = nextTerm; |
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 convertHTML(str) { | |
return str.replace(/[&<>"']/g, (match) => { | |
switch(match){ | |
case "&": | |
return "&"; | |
case '"': | |
return """; | |
case "'": | |
return "'"; |
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 uniteUnique(...arr) { | |
let resultArray = arr[0]; | |
for(let i = 0; i < arr.length-1; i++){ | |
resultArray = compareArrays(resultArray, arr[i+1]); | |
} | |
return resultArray; | |
} |
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 fearNotLetter(str) { | |
let charCodes = str.split("").map(code=>{ | |
return code.charCodeAt(0); | |
}).sort((a, b)=>a-b); | |
let missingCode = charCodes[0]; | |
for(let i = 0; i < charCodes.length; i++){ | |
if(missingCode == charCodes[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
function pairElement(str) { | |
let pairedDNA = []; | |
str.split("").forEach(strand=>{ | |
let paired; | |
switch(strand){ | |
case 'G': | |
paired = ['G', 'C']; |