-3
The code is not adding, just joining (concatenating*) the numbers
var media = "";
var media2 = "";
var media3 = "";
var media4 = "";
function myFunction(){
media = Number(document.getElementById("vnota").value);
media2 = Number(document.getElementById("vnota2").value);
media3 = Number(document.getElementById("vnota3").value);
media4 = Number(document.getElementById("vnota4").value);
document.getElementById("notas").innerHTML = "A sua nota final é: " + media + media2 + media3 + media4;
}
"Putting together" you mean "concatenating", it’s not?
– G. Bittencourt
Try to put the sum in parentheses (
"A sua nota final é: " + (media + media2 + media3 + media4)
). If not you can add before and save to a variable,total
, for example– Costamilam
It worked, thanks bro! <3
– THΔLES