Skip to content
Advertisement

Simple calculator in HTML and JavaScript

I have to write a calculator in HTML. I really can’t find what is going wrong and it does not show the results. I can’t find something wrong can you help? I’m running it in Chrome.

JavaScript File and and the HTML:

JavaScript
JavaScript

Advertisement

Answer

Things to fix: 1) Assign to value, not innerHTML, when referring to an input element. (They have no content, hence no innerHTML. 2) Start a function declaration with the keyword function. 3) It’s parseFloat, not parsefloat. JavaScript is case-sensitive.

Minimally fixed code:

JavaScript
JavaScript
Advertisement