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
console.log("This code will check to see if there are any even numbers"); | |
var numere = [3, 5, 7, 33, 13, 15, 787, 1345, 1357, 1231435, 88]; | |
var pare=[]; //locul unde se vor aduna toate nr pare | |
function par (a) { //functie pt a returna True/False pt numarul introdus | |
if (a%2==0) { | |
return true; | |
} else { | |
return false; | |
}} |
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
//var myNumber = [10, 20, 30, [100, 200], 40, 50]; //your simple array | |
var myNumber = [1,5,[1,2],[3,4],10,9,[5],[6,[99,99,[99,[88,88,[77,77]],99]]]];//multilevel array | |
//var myNumber = [7,6,5,4,3,[[[[0]]]]];//no depth array | |
console.log("This code will dinamically display ONLY the second level of the following array:\n"+JSON.stringify(myNumber)+'\n'); | |
// Solution #A ===================================== | |
for(i=0;i<myNumber.length;i++){ | |
var lvlTwoCount=0;//Pt cand nu este nici un level 2 in array | |
for(j=0;j<myNumber[i].length;j++){ | |
if (myNumber[i][j]!=0) {//am scris mai jos rolul intentionat pt acest if |