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 getSeries(limit){ | |
var series = ""; | |
var counter = 1; | |
for(var i=1; i>0; i+=counter){ | |
if(i==limit){ | |
counter= -1; | |
} | |
series += (i + " "); | |
}; |
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
/** | |
*Simpler solution using for loop; without using any array.indexOf() | |
*/ | |
Array.prototype.getIndicesOf = function(item){ | |
var indices = []; | |
for(var i=0; i < this.length; i++){ | |
if(this[i] === item){ | |
indices.push(i); |
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
/** | |
*Simpler solution using for loop; without using any array.indexOf() | |
*/ | |
Array.prototype.getIndicesOf = function(item){ | |
var indices = []; | |
for(var i=0; i < this.length; i++){ | |
if(this[i] === item){ | |
indices.push(i); |