Skip to content

Commit

Permalink
basics - got to arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi-Fogel committed Dec 19, 2024
1 parent 109f220 commit 12de371
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions a_temp_deleteME/basics1.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,49 @@ while(required){
required= false;
}

// from 1->10 give common multiple values of 2 and 5
// from, and/or loops
for(let k=0; k<=10; k++){
if(k%2 == 0)
console.log("for loop - multiple 2, 5: " + k)
}
if(k%2 == 0 && k%5 == 0)
console.log("for loop - multiple 2 AND 5: " + k)
}
for(let k=0; k<=10; k++){
if(k%2 == 0 || k%5 == 0)
console.log("for loop - multiple 2 OR 5: " + k)
}

let n = 0;
for(let k=0; k<=100; k++){
if(k%2 == 0 && k%5 == 0){
n++;
console.log("for loop - multiple 2 OR 5 - first 3 characters: " + k);
if (n==3);
break;
}

}

console.log("########################################################")
console.log("ARRAYS");
var marks = Array(6);
var marks = new Array(20, 40, 35, 12, 38);

var marks = [20, 40, 35, 12, 38];
mySubArray = marks.slice(2,5);
console.log("subArray: " + mySubArray);

console.log(marks[2]);

marks[3] = 15;
console.log(marks[3]);

console.log("array length: " + marks.length);

marks.push(65);//append
console.log(marks);
marks.pop();
console.log(marks);
marks.unshift(1); // 1st position

console.log("number on posistion: " + marks.indexOf(38));
console.log("120 part of array? " + marks.includes(120));

0 comments on commit 12de371

Please sign in to comment.