pushing values from objects to array

This commit is contained in:
2021-10-06 11:47:13 -05:00
parent 969af4adfd
commit 2f85e465d5
+11 -8
View File
@@ -1,7 +1,8 @@
const toys = [ const toys = []
const createtoyobj = (number,toyname, typename, unitprice, stockst,description,toyman ) => { const createtoyobj = (number,toyname, typename, unitprice, stockst,description,toyman ) => {
return { const newOBJ = {
id: number, id: number,
name: toyname, name: toyname,
type: typename, type: typename,
@@ -11,14 +12,16 @@ const toys = [
manufacturer: toyman 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 buildingBlocks = createtoyobj(1, "building blocks", "construction toy", `${50.00}`,true,"Quality building blocks for inquiring and creative minds", "Hasboro");
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 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(buildingBlocks);
console.log(hotWheels); console.log(hotWheels);
console.log(stuffedAnimals); console.log(stuffedAnimals);
console.log(toys)