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 (data, replace) { | |
| //Replace all values of "dynamic" with replace | |
| if (data == null) | |
| return data; | |
| for (var prop in data) | |
| if (data.hasOwnProperty(prop)) { | |
| if (data[prop] == "dynamic") | |
| data[prop] = replace; | |
| } |
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 tribonacci(signature,n){ | |
| console.log(signature); | |
| console.log(n); | |
| var i; | |
| var fib = new Array(); | |
| if (n == 0) return fib; | |
| if (n > 3) { | |
| fib[0] = signature[0]; | |
| fib[1] = signature[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 isIntArray(arr) { | |
| console.log(arr); | |
| if (arr == null) return false; | |
| if (arr.constructor !== Array || arr == null) return false; | |
| if (arr.length < 1) return true; | |
| for (var i = 0; i < arr.length; i++) | |
| if ((arr[i] % 1 != 0)) return false; | |
| else |
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 isTriangleNumber(number) { | |
| if (isNaN(number) || number != parseInt(number, 10)) return false; | |
| else if (number == 0 || number == 1) return true; | |
| else | |
| var m = (Math.sqrt(8*number+1) - 1) / 2; | |
| if (m != parseInt(m,10)) return false; | |
| else return true; | |
| } |
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 Node(data) { | |
| this.data = data; | |
| this.next = null; | |
| } | |
| function length(head) { | |
| if (head == null) | |
| return 0; | |
| else |
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 isPrime(num) { | |
| var start = 2; | |
| while (start <= Math.sqrt(num)) { | |
| if (num % start++ < 1) return false; | |
| } | |
| return num > 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
| var countBits = function(n) { | |
| var bRep = (n >>> 0).toString(2); | |
| var digits = (bRep).toString(10).split("").map(function(t){return parseInt(t)}); | |
| console.log(digits); | |
| var k =0; | |
| for (var i = 0; i < digits.length; i++) { | |
| if (digits[i] == 1) { | |
| k++ ; | |
| } | |
| } |
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 findOutlier(integers){ | |
| var length = integers.length, i; | |
| var evens = []; | |
| var odds = []; | |
| var k | |
| for (i=0; i<length; i++) { | |
| if (integers[i] % 2 == 0) { | |
| evens.push(integers[i]); | |
| } | |
| if (Math.abs(integers[i] % 2) == 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 spinWords(str){ | |
| var splitWords = str.split(' '); | |
| var length = splitWords.length; | |
| for(var i = 0; i < length; i++) | |
| { | |
| if (splitWords[i].length >= 5 ) | |
| { | |
| splitWords[i] = reverseWords(splitWords[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 collatz(n){ | |
| var i = 0, c = []; | |
| c.push(n); | |
| while (c[i] > 1) { | |
| if (c[i] % 2 == 0) { | |
| c.push(c[i] / 2); | |
| } | |
| else if (Math.abs(c[i] % 2) == 1) { | |
| c[i] = (c[i] * 3) + 1; |
OlderNewer