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
| /* | |
| Solution for HackerRank > Algorithms > Warmup > Compare the Triplets | |
| https://www.hackerrank.com/challenges/compare-the-triplets | |
| */ | |
| function main() { | |
| var A = [5,6,7]; | |
| var B = [3,6,10]; | |
| // Set counters to '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
| /* | |
| Solution for HackerRank > Algorithms > Warmup > A Very Big Sum | |
| https://www.hackerrank.com/challenges/a-very-big-sum | |
| */ | |
| function main() { | |
| var n = 5 | |
| var arr = [1000000001,1000000002,1000000003,1000000004,1000000005]; | |
| // Add all values in the array |
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
| /* | |
| Solution for HackerRank > Algorithms > Warmup > Diagonal Difference | |
| https://www.hackerrank.com/challenges/diagonal-difference | |
| */ | |
| function main() { | |
| var n = 3; | |
| var a = [[11,2,4],[4,5,6],[10,8,-12]]; | |
| // Set counters to '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
| /* | |
| Solution for HackerRank > Algorithms > Warmup > Plus Minus | |
| https://www.hackerrank.com/challenges/plus-minus | |
| */ | |
| function main() { | |
| var n = 6; | |
| var arr = [-4,3,-9,0,4,1]; | |
| // Set counters to '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
| /* | |
| Solution for HackerRank > Algorithms > Strings > Pangrams | |
| https://www.hackerrank.com/challenges/pangrams | |
| */ | |
| function main(input) { | |
| var alpha = 'abcdefghijklmnopqrstuvwxyz'; | |
| var i = 0, char, index; | |
| // Simplify string |
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
| /* Requires: | |
| 1 canvas (var ringTimer) | |
| */ | |
| var ringTimer = document.getElementById('ringTimer').getContext('2d'); | |
| var rSec = 0; | |
| var length_i, endPoint, arcVal; | |
| function drawRingTimer(){ | |
| // ------------------------------------- Reset Canvas |
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
| /* Requires: | |
| 1 time container (var Timer) | |
| 1 start/reset button (var startReset) | |
| */ | |
| // ------------------------------------- Start & Reset Functions | |
| function startTimer() { | |
| sec = 59; | |
| countdown = setInterval(currentTime, 1000); | |
| toggle = false; |
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 that will be used as a template | |
| function Book(title, author, alreadyRead) { | |
| this.title = title; | |
| this.author = author; | |
| this.alreadyRead = alreadyRead; | |
| } | |
| // ------------------------------------- New objects created from Book() | |
| var bookArray = [ | |
| new Book("Dune", "Frank Herbert", false), |
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
| // ------------------------------------- Create an array for the ordered list | |
| var podcasts = [ | |
| '99% Invisible', | |
| 'The Light Bulb', | |
| 'Planet Money', | |
| 'Radiolab', | |
| 'TED Radio Hour', | |
| 'StarTalk Radio', | |
| 'The Vergecast', | |
| 'Song Exploder', |
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 parity(val){ | |
| return (val % 2 === 0) ? 'even' : 'odd'; | |
| } | |
| // Fixes negative number mod | |
| function mod(x, m){ | |
| return (x % m >= 0) ? (x % m) : (x % m + m); | |
| } | |
| function squared(num) { |
NewerOlder