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 wordMachine = (commands) => { | |
const operations = commands.split(' '); | |
let stack = []; | |
commandCount = 0; | |
operations.map((item, index) => { | |
let detectInteger = parseInt(item); | |
commandCount++; | |
//console.log(stack); |
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 ContiguousGroups = (array) => { | |
const arrayValues = array.sort(); | |
let contiguousCount = 0, | |
foundMatch = false; | |
arrayValues.map(function(item, index) { | |
let findDifference = Math.abs(item - arrayValues[index + 1]); | |
if (!isNaN(findDifference) && findDifference === 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 Min = (array) => { | |
const min = Math.min(...array); | |
return min; | |
} | |
const Max = (array) => { | |
const max = Math.max(...array); | |
return max; | |
} |
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 BubbleSort = (values) => { | |
let originalValues = values.slice(), | |
length = originalValues.length - 1, | |
swapped; | |
do { | |
swapped = false; | |
values.forEach((item, index, values) => { | |
let currentItem = values[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
const binaryGaps = (number) => { | |
let binaryConversion = number.toString(2); | |
binaryConversion | |
return binaryConversion; | |
} |
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
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
let sum = null, | |
previous_sum = 0, | |
next_sum = null; | |
if(!A || A.length === 0) { | |
return -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
sequenceClassifier = (arr) => { | |
let classifier = null, | |
strictlyIncreased = 1, | |
strictlyDecreased = 1, | |
constant = 1, | |
hasDecreased = false, | |
hasIncreased = false | |
arr.map(function(item, 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
var maxSequence = function(array) { | |
let currentMax = max = 0 | |
array.map(function(item, index){ | |
// make sure current is greater than zero | |
currentMax = Math.max(0, currentMax + array[index]) | |
// replace max with current max if greater | |
max = Math.max(max, currentMax) | |
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 digitalRoot(number) { | |
let lengthCheck = '' | |
const originalNumber = number | |
function add(a, b) { | |
this.a = parseInt(a) | |
this.b = parseInt(b) | |
return this.a + this.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 disemvowel(str) { | |
return str.replace(/[aeiouy]/ig,'').toString(); | |
} | |
console.log(disemvowel('This website is for losers LOL!')) |
OlderNewer