From f75860148b7fe48c3795b8e95afcc1802610777d Mon Sep 17 00:00:00 2001 From: uhuru3 Date: Sat, 10 Nov 2018 17:35:35 -0800 Subject: [PATCH 1/4] loops completed --- 04week/loop.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/04week/loop.js b/04week/loop.js index e69de29bb..9d60f5402 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -0,0 +1,30 @@ +// Use a for loop to console.log each item in the array carsInReverse + + +// 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){ + console.log(`${prop} = ${keyBirth[prop]}`) +} + +// Use a for loop to console.log the numbers 1 to 1000 (while loop) +let grade = 0; +while (grade < 60){ + grade += 10; + console.log("You have a " + grade + " in this class and cannot move on to the next class until your grade is higher than a 70."); +} From 87f4d0a775d5ab621822ac8471df9d12f0890a1e Mon Sep 17 00:00:00 2001 From: uhuru3 Date: Mon, 12 Nov 2018 18:54:29 -0800 Subject: [PATCH 2/4] loops corrected --- 04week/loop.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/04week/loop.js b/04week/loop.js index 9d60f5402..4437b910e 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -1,4 +1,14 @@ // Use a for loop to console.log each item in the array carsInReverse +const carsInReverse = { + car1: 'Ford', + car2: 'Honda', + car3: 'Lincoln', + car4: '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: @@ -19,12 +29,14 @@ for (const prop in persons) { keyBirth = persons.birthDate for(const prop in keyBirth){ + if(keyBirth) console.log(`${prop} = ${keyBirth[prop]}`) } + // Use a for loop to console.log the numbers 1 to 1000 (while loop) -let grade = 0; -while (grade < 60){ - grade += 10; - console.log("You have a " + grade + " in this class and cannot move on to the next class until your grade is higher than a 70."); +let loopNum = 0; +while (loopNum < 1000){ + loopNum += 1000; + console.log(loopNum); } From eba153921fcad90509f4b48c3c5f3905e2f126fc Mon Sep 17 00:00:00 2001 From: uhuru3 Date: Tue, 13 Nov 2018 17:35:59 -0800 Subject: [PATCH 3/4] final edits --- 04week/loop.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/04week/loop.js b/04week/loop.js index 4437b910e..84b689b36 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -1,14 +1,9 @@ // Use a for loop to console.log each item in the array carsInReverse -const carsInReverse = { - car1: 'Ford', - car2: 'Honda', - car3: 'Lincoln', - car4: 'Chevy' - }; +const carsInReverse = ['Ford', 'Honda', 'Lincoln', 'Chevy']; for(let i = 0; i < carsInReverse.length; i++){ - console.log(carsInReverse[i]); - } + console.log(carsInReverse[i]); + } // Create an object (an array with keys and values) called persons with the following data: @@ -25,18 +20,18 @@ 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 +// 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) + 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 = 0; -while (loopNum < 1000){ - loopNum += 1000; +let loopNum = 1; +while (loopNum < 1001){ + loopNum += 1; console.log(loopNum); } From 7d6d6625282d1dd34c85419de5e1400a6ad7276f Mon Sep 17 00:00:00 2001 From: Nat Turner Date: Mon, 10 Dec 2018 18:09:41 -0600 Subject: [PATCH 4/4] higherOrder completed --- 06week/higherOrder.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/06week/higherOrder.js b/06week/higherOrder.js index 73926e3dc..bfea242db 100644 --- a/06week/higherOrder.js +++ b/06week/higherOrder.js @@ -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') {