Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here is my code: //class created class Shoes { constructor(name, code, quantity, valuePerItem) { this.Name = name; this.ProductCode = code; this.Quantity = quantity; this.ValuePerItem =

here is my code:

//class created class Shoes { constructor(name, code, quantity, valuePerItem) { this.Name = name; this.ProductCode = code; this.Quantity = quantity; this.ValuePerItem = valuePerItem; } } //function to search the shoes function search(shoes, shoe){ let found = false; shoes.forEach(ele => { if(ele.Name==shoe){ alert("Shoe found."); found = true; } }); if(!found){ alert("Shoe not found.") } } //function to search the shoe with the lowest value per item function lowest(shoes){ let low = shoes[0].ValuePerItem; let name = ""; shoes.forEach(shoe=>{ if (shoe.ValuePerItem{ if (shoe.ValuePerItem>high){ high = shoe.ValuePerItem; name = shoe.Name; } }) alert(`Shoe with highest value per item is ${name} with value of ${high}`) } //function to edit any aspect of an instance of the shoes class function edit(shoe, name="", code="", quantity="", price=""){ shoes.forEach(ele=>{ if(ele.ProductCode==shoe.ProductCode){ if(name){ ele.Name = name; } if(code){ ele.ProductCode = code; } if(quantity){ ele.Quantity = quantity; } if(price){ ele.ValuePerItem = price; } } alert("Details edited successfully.") }) } //function to order all of the objects in ascending order(sort) function sort(shoes){ return shoes.sort(); } let shoe1 = new Shoes("Puma", 123, 50, 2000); let shoe2 = new Shoes("Reebok", 150, 20, 7000); let shoe3 = new Shoes("Nike", 191, 70, 1000); let shoe4 = new Shoes("Adidas", 527, 10, 8000); let shoe5 = new Shoes("Vans", 790, 150, 3000); let shoes = [shoe1, shoe2, shoe3, shoe4, shoe5]; search(shoes, "Puma"); lowest(shoes); highest(shoes); edit(shoes[1], "New Balance", 100, 10, 4599); sort(shoes);

lecturers review: In your search function you should return the actual object and not just a string that says "shoe found" . Your sort function is not sorting the array of objects.

Please help me fix this code to the lecturers comments.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions