From 8310d48b47c4aa51a28c26a2eff7a1bc13a0cbfa Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Thu, 7 Oct 2021 11:57:33 -0500 Subject: [PATCH 1/4] ch 7 excercise, but whatever --- scripts/leonids-toys.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index 12ee2d5..814bfe6 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -22,7 +22,6 @@ const buildingBlocks = createtoyobj(1, "building blocks", "construction toy", `$ const hotWheels = createtoyobj(2,"hot wheels set", "toy vehicles",`${100.00}`, true, "Beautifully painted model cars! Durable and will keep children entertained for hours. (Not for children under the age of 5, small parts/swallowing hazard", "Mattel"); const stuffedAnimals = createtoyobj(3,"Beanie Babies", "Stuffed Animals", `${15.00}`, false, "Soft, plushy, and cute! Perfect for infants all the way up to 7 years old!", "Beanie Babies"); -toys.push(buildingBlocks, hotWheels, stuffedAnimals) /* for (const toy of toys) { console.log(toys) @@ -52,10 +51,9 @@ const dumptruck = createtoyobj(4,"dump truck", "toy vehicles", `${150.00}`, true const racetrack = createtoyobj(5, "Race Track", "toy vehicles", `${200.00}`, false, "Fun place for kids to race their hotwheels!","Neumann" ) -toys.push(dumptruck, racetrack) +toys.push(dumptruck, racetrack,buildingBlocks, hotWheels, stuffedAnimals) -console.log(toys); for(const toy of toys){ - console.log(toy.name) + console.log(`The ${toy.name} costs ${toy.price}.`) } \ No newline at end of file -- 2.47.3 From 0dc0171f4446a11a6df4604dde01070b4ed6851b Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Thu, 7 Oct 2021 14:07:58 -0500 Subject: [PATCH 2/4] updating toy changes for filter --- scripts/leonids-toys.js | 46 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index 814bfe6..211ffa5 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -1,26 +1,25 @@ - const toys = [] - const createtoyobj = (number,toyname, typename, unitprice, stockst,description,toyman ) => { - const newOBJ = { - id: number, - name: toyname, - type: typename, - price: unitprice, - stockstatus: stockst, - itemdescription: description, - manufacturer: toyman - +const createtoyobj = (number, toyname, typename, unitprice, stockst, description, toyman) => { + const newOBJ = { + id: number, + name: toyname, + type: typename, + price: unitprice, + stockstatus: stockst, + itemdescription: description, + manufacturer: toyman + } return newOBJ - + } -const buildingBlocks = createtoyobj(1, "building blocks", "construction toy", `${50.00}`,true,"Quality building blocks for inquiring and creative minds", "Hasboro"); -const hotWheels = createtoyobj(2,"hot wheels set", "toy vehicles",`${100.00}`, true, "Beautifully painted model cars! Durable and will keep children entertained for hours. (Not for children under the age of 5, small parts/swallowing hazard", "Mattel"); -const stuffedAnimals = createtoyobj(3,"Beanie Babies", "Stuffed Animals", `${15.00}`, false, "Soft, plushy, and cute! Perfect for infants all the way up to 7 years old!", "Beanie Babies"); +const buildingBlocks = createtoyobj(1, "building blocks", "construction toy", `${50.00}`, true, "Quality building blocks for inquiring and creative minds", "Hasboro"); +const hotWheels = createtoyobj(2, "hot wheels set", "toy vehicles", `${100.00}`, true, "Beautifully painted model cars! Durable and will keep children entertained for hours. (Not for children under the age of 5, small parts/swallowing hazard", "Mattel"); +const stuffedAnimals = createtoyobj(3, "Beanie Babies", "Stuffed Animals", `${15.00}`, false, "Soft, plushy, and cute! Perfect for infants all the way up to 7 years old!", "Beanie Babies"); /* for (const toy of toys) { @@ -47,13 +46,18 @@ for(stuffedAnimal of stuffedAnimals) { } */ -const dumptruck = createtoyobj(4,"dump truck", "toy vehicles", `${150.00}`, true, "High quality fully aluminum and steel construction!", "Tonka") +const dumptruck = createtoyobj(4, "dump truck", "toy vehicles", `${150.00}`, true, "High quality fully aluminum and steel construction!", "Tonka") -const racetrack = createtoyobj(5, "Race Track", "toy vehicles", `${200.00}`, false, "Fun place for kids to race their hotwheels!","Neumann" ) +const racetrack = createtoyobj(5, "Race Track", "toy vehicles", `${200.00}`, false, "Fun place for kids to race their hotwheels!", "Neumann") -toys.push(dumptruck, racetrack,buildingBlocks, hotWheels, stuffedAnimals) +toys.push(dumptruck, racetrack, buildingBlocks, hotWheels, stuffedAnimals) + + +for (const toy of toys) { + toy.price = toy.price * 1.05 + + console.log(`The ${toy.name} costs ${toy.price}.`) + } + -for(const toy of toys){ - console.log(`The ${toy.name} costs ${toy.price}.`) -} \ No newline at end of file -- 2.47.3 From 9f46cf30baf5d1d716320125ca40a4cf82a79772 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Thu, 7 Oct 2021 14:22:37 -0500 Subject: [PATCH 3/4] completed filter project --- scripts/leonids-toys.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index 211ffa5..f160270 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -52,11 +52,12 @@ const racetrack = createtoyobj(5, "Race Track", "toy vehicles", `${200.00}`, fal toys.push(dumptruck, racetrack, buildingBlocks, hotWheels, stuffedAnimals) - +toyID = 1 for (const toy of toys) { - toy.price = toy.price * 1.05 - - console.log(`The ${toy.name} costs ${toy.price}.`) + if(toyID === toy.id){ + toy.price = toy.price * 1.05 + console.log(`The ${toy.name} costs ${toy.price}.`) + } } -- 2.47.3 From 09e5db49c3d93b6ed973ae11912eb6fca5e35705 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Thu, 7 Oct 2021 15:51:40 -0500 Subject: [PATCH 4/4] Finished toy project --- scripts/leonids-toys.js | 79 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index f160270..41e8dd4 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -1,8 +1,23 @@ -const toys = [] +toyID = 1 -const createtoyobj = (number, toyname, typename, unitprice, stockst, description, toyman) => { +const toys = [] +/* const toyfactory = (randomtoyOBJ) => { + if (toys.length < 1) { + randomtoyOBJ.id = 1 + } else { + + const lastIndex = toys.length - 1 + const currentLastToy = toys[lastIndex] + const maxId = currentLastToy.id + const idForNewToy = maxId + 1 + randomtoyOBJ.id = idForNewToy + } + // console.log(randomtoyOBJ, "This is a generated toy OBJ") + toys.push(randomtoyOBJ) + } */ + +const createtoyobj = (toyname, typename, unitprice, stockst, description, toyman) => { const newOBJ = { - id: number, name: toyname, type: typename, price: unitprice, @@ -11,48 +26,30 @@ const createtoyobj = (number, toyname, typename, unitprice, stockst, description manufacturer: toyman } - return newOBJ - + if (toys.length < 1) { + newOBJ.id = 1 + } else { + + const lastIndex = toys.length - 1 + const currentLastToy = toys[lastIndex] + const maxId = currentLastToy.id + const idForNewToy = maxId + 1 + newOBJ.id = idForNewToy + } + toys.push(newOBJ) + } +const buildingBlocks = createtoyobj("building blocks", "construction toy", `${50.00}`, true, "Quality building blocks for inquiring and creative minds", "Hasboro"); + +const hotWheels = createtoyobj("hot wheels set", "toy vehicles", `${100.00}`, true, "Beautifully painted model cars! Durable and will keep children entertained for hours. (Not for children under the age of 5, small parts/swallowing hazard", "Mattel"); +const stuffedAnimals = createtoyobj("Beanie Babies", "Stuffed Animals", `${15.00}`, false, "Soft, plushy, and cute! Perfect for infants all the way up to 7 years old!", "Beanie Babies"); + +const dumptruck = createtoyobj("dump truck", "toy vehicles", `${150.00}`, true, "High quality fully aluminum and steel construction!", "Tonka") +const racetrack = createtoyobj("Race Track", "toy vehicles", `${200.00}`, false, "Fun place for kids to race their hotwheels!", "Neumann") +console.log(toys) -const buildingBlocks = createtoyobj(1, "building blocks", "construction toy", `${50.00}`, true, "Quality building blocks for inquiring and creative minds", "Hasboro"); -const hotWheels = createtoyobj(2, "hot wheels set", "toy vehicles", `${100.00}`, true, "Beautifully painted model cars! Durable and will keep children entertained for hours. (Not for children under the age of 5, small parts/swallowing hazard", "Mattel"); -const stuffedAnimals = createtoyobj(3, "Beanie Babies", "Stuffed Animals", `${15.00}`, false, "Soft, plushy, and cute! Perfect for infants all the way up to 7 years old!", "Beanie Babies"); - - -/* for (const toy of toys) { - console.log(toys) -} */ - - -/* console.log(buildingBlocks); -console.log(hotWheels); -console.log(stuffedAnimals); */ - -// console.log(buildingBlocks.id); - -/* for(const buildingBlock of buildingBlocks) { - console.log(buildingBlock.name) -} - -for(const hotWheel of hotWheel) { - console.log(hotWheel.name) -} - -for(stuffedAnimal of stuffedAnimals) { - console.log(stuffedAnimal.name) -} -*/ - -const dumptruck = createtoyobj(4, "dump truck", "toy vehicles", `${150.00}`, true, "High quality fully aluminum and steel construction!", "Tonka") - -const racetrack = createtoyobj(5, "Race Track", "toy vehicles", `${200.00}`, false, "Fun place for kids to race their hotwheels!", "Neumann") - -toys.push(dumptruck, racetrack, buildingBlocks, hotWheels, stuffedAnimals) - -toyID = 1 for (const toy of toys) { if(toyID === toy.id){ toy.price = toy.price * 1.05 -- 2.47.3