Help to solve Javascript task
Budget: $10 – $30 USD
Hi
Can you please help to write the javascript code to resolve the following task? This is for beginners so the answer should not be too advanced.
Task:
Select the button with the class price. When the button is clicked, loop through the array below, add all the prices and assign the total to be the innerHTML value of the element with the id total.
var toys = [
{
name: "Lego",
price: 15.6,
},
{
name: "Master of the Universe",
price: "28.3",
},
{
name: "Barbie",
price: null,
},
{
name: "Mr Potato Head",
price: 89.99,
},
];
HTML:
<body>
<div class="container">
<h1>Programming Foundations Course Assignment</h1>
<ul class="games"></ul>
<div id="subtraction"></div>
<button type="button" class="page">Change page</button>
<button type="button" class="price">Calculate price</button>
<div id="total"></div>
</div>
<script src="js/script.js"></script>
</body>
Can you please help to write the javascript code to resolve the following task? This is for beginners so the answer should not be too advanced.
Task:
Select the button with the class price. When the button is clicked, loop through the array below, add all the prices and assign the total to be the innerHTML value of the element with the id total.
var toys = [
{
name: "Lego",
price: 15.6,
},
{
name: "Master of the Universe",
price: "28.3",
},
{
name: "Barbie",
price: null,
},
{
name: "Mr Potato Head",
price: 89.99,
},
];
HTML:
<body>
<div class="container">
<h1>Programming Foundations Course Assignment</h1>
<ul class="games"></ul>
<div id="subtraction"></div>
<button type="button" class="page">Change page</button>
<button type="button" class="price">Calculate price</button>
<div id="total"></div>
</div>
<script src="js/script.js"></script>
</body>