diff --git a/04week/loop.js b/04week/loop.js index e69de29bb..3feda09d2 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -0,0 +1,79 @@ +// Use a do...while loop to console.log the numbers from 1 to 1000. +let n = 0; +do { + n += 1 + console.log(n) +} while (n<1000); + +// Create an object (an array with keys and values) called person with the following data: + +// firstName: "Jane" +// lastName: "Doe" +// birthDate: "Jan 5, 1925" +// gender: "female" + +let person = { + firstName: "Jane", + lastName: "Doe", + birthDate: ["Jan 5, 1925", "Jan 6, 1926"], + gender: "female", +} + +// Use a for...in loop and if statement to console.log the value associated with the key birthDate if the birth year is an odd number. + +let oddNumbers = [1,3,5,7,9]; +let i = ""; +for (i in person) { + for (n=0;n console.log(x)) + +// Use .filter() to filter the persons array and console.log only males in the array. +arrayOfPersons.filter(x => console.log(x.gender == 'male')) + +// Use .filter() to filter the persons array and console.log only people that were born before Jan 1, 1990. +function year() { + for (i=0;i ...) + \ No newline at end of file