From db9a5907c1086295a757a147d96fd36e360af478 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Mon, 29 Jun 2020 20:05:08 -0500 Subject: [PATCH 1/2] changes --- 04week/loop.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/04week/loop.js b/04week/loop.js index e69de29bb..f04576273 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -0,0 +1,21 @@ +/** + * Use a do While loop to console.log numbers from 1 to 1000. + * */ +const colors = ['orange', 'red', 'blue', 'yellow', 'green', 'purple']; + +const tieDyes = colors.map((color) => { + return `tieDyed-${color}`; +}); + +console.log(tieDyes); + +let result = ''; +let i = 0; + +do { + i = i + 1; + result = result + i; +} while (i < 1000); + +console.log(result); +// expected result: "12345" From 179a26a76615c4326893404d3e058d88fa3b79b7 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Fri, 3 Jul 2020 14:47:53 -0500 Subject: [PATCH 2/2] finished --- 04week/loop.js | 82 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 13 deletions(-) diff --git a/04week/loop.js b/04week/loop.js index f04576273..8e9b74778 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -1,14 +1,5 @@ -/** - * Use a do While loop to console.log numbers from 1 to 1000. - * */ -const colors = ['orange', 'red', 'blue', 'yellow', 'green', 'purple']; - -const tieDyes = colors.map((color) => { - return `tieDyed-${color}`; -}); - -console.log(tieDyes); - +'use strict' +// the do while loop is still a little fuzzy to me. let result = ''; let i = 0; @@ -17,5 +8,70 @@ do { result = result + i; } while (i < 1000); -console.log(result); -// expected result: "12345" +//console.log("this is my console logged result!", result); +// next i need to create an object + +const sampleObject = { + firstName: "Jane", + lastName:"Doe", + birthDate: "Jan 5, 1925", + gender: 'Female' +} +//defining property in chris +for (let property in sampleObject){ + //if property equals birthDate + if (property === "birthDate"){ + //let the oddYear be the birthdate defined as a number as well as slice the end of the birthdate to return the year + let oddYear = parseInt(sampleObject["birthDate"].slice(-4)); + //if the odd year isnt divisible by 2 then it would mean it is a odd number + (oddYear % 2 !== 0) + //console.log("this should display odd year", oddYear) + } + +} + + +/** + * making an array of people + */ +let arrayOfPeople = [ + { + firstName: "Jane", + lastName:"Doe", + birthDate: "Jan 5, 1995", + gender: 'Female' +}, + { + firstName: "Hitzel", + lastName:"Betts", + birthDate: "Aug 30, 1996", + gender: 'Female' +}, +{ + firstName: "Cooper", + lastName:"Trevino", + birthDate: "March 5, 1930", + gender: 'Male' +}, +{ + firstName: "Bonnie", + lastName:"Trevino", + birthDate: "Oct 9, 2013", + gender: 'Female' +}]; +//console.log(arrayOfPeople); + +//need to use map to map over the array of persons and console.log information + +arrayOfPeople.map(function(info){ + return info +}) +//console.log(arrayOfPeople) +//using the filter method to get the males out only +let isMale = arrayOfPeople.filter(arrayOfPeople => arrayOfPeople.gender === "Male"); +console.log(isMale); +//need to filter out the people born before 1990 +let stillGotTime = arrayOfPeople.filter(birthDate => birthDate["birthDate"].slice(-4) < "1990"); +console.log(stillGotTime); + +