Message from JavaScript discussions
July 2018
— Maybe is your browser, in my browser run correctly
You can fix it with document.getElementById("total_return").innerHTML = total_return + (amount*percent*days+Number(amount));
The first parenthesis is to tell javascript the last sum is not a concatenation and the Number around amount because amount is a string and you don't want to concatenate
Or you can do a thing like: document.getElementById("total_return").innerHTML = total_return + (amount*percent*days+(+amount));
Because the (+amount)
tells Javascript to use it like a number.
— No, it doesn't. It should be like this
— Works with 2th
— Really thanks!!
— 👍
— Well the parenthesis are to ensure there is no expression in the left hand of the +
operator.
— And this other thing was also happening.
— Ok
— 😄
— Ye
— What do you guys consider to be the best learning resources in this department next to the docs?