Javascript widget to replace the original price with discounted price

Javascript widget to replace the original price with discounted price
0

#1

An e-commerce website has a page with multiple products in it. Each product has a price tag below the product image. i have to create a widget which when included finds all these price tags and puts a new price label just below the original price showing the discounted price.

The discount rates are

  1. 20% - if the cost of the item is less than $100.

  2. 30% - $100 <= Cost of the item < $500

  3. 40% - Cost of the item >= $500

  4. The minimum cost of the item to get a discount is $20. If there is no discount, there is no need to show any label below the actual price.

  5. The HTML elements which contain the original price tags have class names in the format “price-”. For example, if product Id is 123, the element which holds the price tag has a class named “price-123”.


#2

Do you have a question?


#3

i completed the html layout and i am begginer in javascript so kindly help with this question? how can i solve and the algorithm should i follow ?


#4

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://freecodecamp.org.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

Happy coding :slight_smile: