Archie2033 Archie2033 - 6 months ago 32
HTML Question

What's wrong with this code(JavaScript, buttons, HTML)?

<!DOCTYPE html>
<title>Question 2</title>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<button onClick="myFunction()">Alphabetical order</button>
<button onClick="countFunction">Count</button>

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

var products = ["Printer", "Tablet", "Router", "Keyboard"];
document.getElementById("i").innerHTML = products;

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

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

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 please 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!


Modify these lines:

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

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