Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions 04week/loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Use a for loop to console.log each item in the array carsInReverse
const carsInReverse = ['Ford', 'Honda', 'Lincoln', 'Chevy'];

for(let i = 0; i < carsInReverse.length; i++){
console.log(carsInReverse[i]);
}


// Create an object (an array with keys and values) called persons with the following data:
const persons = {
firstName: "Jane",
lastName: "Doe",
birthDate: "Jan 5, 1925",
gender: "female"
};

const keys = Object.key(persons)
// Use a for...in loop to console.log each key.
for (const prop in persons) {
console.log(`${prop} = ${persons[prop]}`);
};

// Then use a for...in loop and if state, to console.log the value associated with the key birthDate
keyBirth = persons.birthDate

for(const prop in keyBirth){
if(keyBirth==prop.birthDate)
console.log(`${prop} = ${keyBirth[prop]}`)
}


// Use a for loop to console.log the numbers 1 to 1000 (while loop)
let loopNum = 1;
while (loopNum < 1001){
loopNum += 1;
console.log(loopNum);
}
16 changes: 16 additions & 0 deletions 06week/higherOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,38 @@ const assert = require('assert');

function forEach(arr, callback) {
// Your code here
count.forEach(function(count){
console.log(count, 3);
});
}

function map(arr, callback) {
// Your code here
const mapped = mapped.map(function(mapped){
return mapped;
});

}

function filter(arr, callback) {
// Your code here
const filtered = filtered.filter(function(filtered){
return (filtered, [2]);
});
}

function some(arr, callback) {
// Your code here
const somed = somed.some(function(somed){

});
}

function every(arr, callback) {
// Your code here
const everied = everied.every(function(everied){

});
}

if (typeof describe === 'function') {
Expand Down