Archie2033 Archie2033 - 25 days ago 7
HTML Question

What's wrong with this code(Java script, buttons, html)?

<!DOCTYPE html>

<html>

<head>
<title>Question 2</title>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
</head>



<body>


<button onClick="myFunction()">Alphabetical order</button>

<button onClick="countFunction">Count</button>


<p id="i"></p>

<p id="ii"></p>


<script>


var products = ["Printer", "Tablet", "Router", "Keyboard"];

document.getElementById("i").innerHTML = products;


function myFunction() {

products.sort();

document.getElementById("i").innerHTML = products;
}



function countFunction() {
document.getElementById("i").innerHTML = products.length;

}



</script>

</body>

</html>


please help, I think it's just a spelling or formatting error. If you can change the code as little as possible while still fixing it I would appreciate it a lot.If you need any more details just ask. I would be happy to provide as much information as I can to help you help me.

This is for my son he loves traffic lights!/s

Answer

Modify these lines:

<button onClick="myFunction();">Alphabetical order</button>

<button onClick="countFunction();">Count</button>
Comments