I'm actually learning Javascript at a developer school, we have a calculator to make with just html, css and javascript.
I'm almost done, except that I have a problem and can't find the solution.
I have this function
function calcul(operateur){ // fonction du calcul et affichage du résultat
var lcd = document.getElementById("lcd");
switch (operateur){
case "+" :
result = Number(n2) + Number(n1);
console.log(result);
lcd.innerHTML = result;
reset();
break;
case "-" :
result = Number(n2) - Number(n1);
console.log(result);
lcd.innerHTML = result;
reset();
break
case "/" :
result = Number(n2) / Number(n1);
console.log(result);
lcd.innerHTML = result;
reset();
break
case "*" :
result = Number(n2) * Number(n1);
console.log(result);
lcd.innerHTML = result;
reset();
break;
} // résultat affiché, remise à zéro des variables en cas de nouveau calcul par l'utilisateur
Very simple, it just makes a calculation from 2 vars then displays the result in a div in my html file.
My problem is : result is ok when displayed in console, the line right after is putting it in the innerHTML, and it always displays 0... :( I have other functions to display values in the exact same innerHTML and it works almost perfectly fine, so I'm stuck after hours of trying to find why it doesn't work as intented :/
Full html, css and javascript pages (respectively named index.html, BSoverload.css and script.js) are visible in this Github page https://github.com/Mikerhinos/Calc , sorry comments are in french because I'm studying in France so professors are french too.
Thanks to the people who will try to help me :)
break;
in the proper place for your=
case statement block, so it continues down into theC
case statement