From 969af4adfdfaad5b2ead7e148863ca5756123ae0 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Wed, 6 Oct 2021 11:38:44 -0500 Subject: [PATCH 1/4] fixed array declaration --- scripts/leonids-toys.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index 0d4e5c0..da43c7d 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -1,21 +1,23 @@ -const createtoyobj = (number,toyname, typename, unitprice, stockst,description,toyman ) => { - return { - id: number, - name: toyname, - type: typename, - price: unitprice, - stockstatus: stockst, - itemdescription: description, - manufacturer: toyman + +const toys = [ + const createtoyobj = (number,toyname, typename, unitprice, stockst,description,toyman ) => { + return { + id: number, + name: toyname, + type: typename, + price: unitprice, + stockstatus: stockst, + itemdescription: description, + manufacturer: toyman } } +] - -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 = toys.createtoyobj(1, "building blocks", "construction toy", `${50.00}`,true,"Quality building blocks for inquiring and creative minds", "Hasboro"); +const hotWheels = toys.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 = toys.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"); console.log(buildingBlocks); console.log(hotWheels); -- 2.47.3 From 2f85e465d530193560c71211c61727c75f159e23 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Wed, 6 Oct 2021 11:47:13 -0500 Subject: [PATCH 2/4] pushing values from objects to array --- scripts/leonids-toys.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index da43c7d..420e782 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -1,7 +1,8 @@ -const toys = [ +const toys = [] + const createtoyobj = (number,toyname, typename, unitprice, stockst,description,toyman ) => { - return { + const newOBJ = { id: number, name: toyname, type: typename, @@ -11,14 +12,16 @@ const toys = [ manufacturer: toyman } - + return newOBJ + toys.push(newOBJ) } -] -const buildingBlocks = toys.createtoyobj(1, "building blocks", "construction toy", `${50.00}`,true,"Quality building blocks for inquiring and creative minds", "Hasboro"); -const hotWheels = toys.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 = toys.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"); console.log(buildingBlocks); console.log(hotWheels); -console.log(stuffedAnimals); \ No newline at end of file +console.log(stuffedAnimals); +console.log(toys) \ No newline at end of file -- 2.47.3 From 45f80c726f9b041b46fa755bef768f7a24914d8c Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Wed, 6 Oct 2021 13:58:45 -0500 Subject: [PATCH 3/4] Added for loops to display the name properties --- scripts/leonids-toys.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index 420e782..81c38b2 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -13,15 +13,37 @@ const toys = [] } return newOBJ - toys.push(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"); -console.log(buildingBlocks); +toys.push(buildingBlocks, hotWheels, stuffedAnimals) + +/* for (const toy of toys) { + console.log(toys) +} */ +// I don't think I can access the property as it is buried under a function + +/* console.log(buildingBlocks); console.log(hotWheels); -console.log(stuffedAnimals); -console.log(toys) \ No newline at end of file +console.log(stuffedAnimals); */ +console.log(toys); + +console.log(buildingBlocks.id); + +for(const buildingBlocks of buildingBlocks) { + console.log(buildingBlocks.name) +} + +for(const hotWheels of hotWheels) { + console.log(hotWheels.name) +} + +for(stuffedAnimals of stuffedAnimals) { + console.log(stuffedAnimals.name) +} \ No newline at end of file -- 2.47.3 From af274b0cf9029423e16cc88765cd12decc7d9dcb Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Thu, 7 Oct 2021 10:39:13 -0500 Subject: [PATCH 4/4] Completed chapter 5 --- scripts/leonids-toys.js | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/scripts/leonids-toys.js b/scripts/leonids-toys.js index 81c38b2..12ee2d5 100644 --- a/scripts/leonids-toys.js +++ b/scripts/leonids-toys.js @@ -27,23 +27,35 @@ toys.push(buildingBlocks, hotWheels, stuffedAnimals) /* for (const toy of toys) { console.log(toys) } */ -// I don't think I can access the property as it is buried under a function + /* 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) + console.log(toys); -console.log(buildingBlocks.id); - -for(const buildingBlocks of buildingBlocks) { - console.log(buildingBlocks.name) -} - -for(const hotWheels of hotWheels) { - console.log(hotWheels.name) -} - -for(stuffedAnimals of stuffedAnimals) { - console.log(stuffedAnimals.name) +for(const toy of toys){ + console.log(toy.name) } \ No newline at end of file -- 2.47.3