I am busy creating a program in javascript where I have created a class called “Shoes” and given it the properties of “Name”, “Product Code”, “Quantity” and “Value per item”. I then created 5 instances of this. I want to push all 5 instances into an array and then create functions that will find any shoe in the array, find the shoe with the lowest value per item, the shoe with the highest value per item, a function where I can edit any instance of the “Shoes” class and a function that arranges them in ascending order. I am doing this in my spare time and I am struggling
let myArray =[];
class Shoes{
constructor(Name, ProductCode, Quantity, ValuePerItem){
this.Name = Name,
this.ProductCode = ProductCode,
this.Quantity = Quantity,
this.ValuePerItem = ValuePerItem
}
}
const shoe1 = new Shoes("Nike", 001, 500, 2000);
const shoe2 = new Shoes("Puma", 002, 1000, 1500);
const shoe3 = new Shoes("Adidas", 003, 250, 3000);
const shoe4 = new Shoes("Reebok", 004, 2500, 1000);
const shoe5 = new Shoes("Gucci", 005, 100, 5000);
myArray.push(Shoes.shoe1, Shoes.shoe2, Shoes.shoe3, Shoes.shoe4, Shoes.shoe5)
console.log(myArray)
function findShoes(shoe){
let shoe = "Nike";
for(let i = 0; i <= shoe.length; i++){
if(shoe.length === "Nike"){
console.log(shoe[i])
}
}
}
console.log(shoe1, shoe2, shoe3, shoe4, shoe5);