Below is an if statement that I have devised:
var TotalMoney=0;
var Orbs=0;
if (TotalMoney.length==2) {
Orbs+=1;
}
The intention behind this code snippet is to increase the value of "Orbs" by 1 when the digit length of "TotalMoney" equals 2. However, it's currently not functioning as expected. While troubleshooting, I realized that the issue lies within this code block itself. Although there are HTML and CSS elements tied to it, the problem persists. Any help in rectifying this would be greatly appreciated!
I stumbled upon another query while working with this code:
var totalMoney=0;
var orbs=0;
if (totalMoney.toString().length==2) {
orbs+=1;
}
This logic successfully identifies when the number has 2 digits, but now a new challenge arises. Whenever the number increments from 10 onwards (up to 99), it continuously adds an orb for each increment. My goal is for it to only add 1 orb when the number reaches double digits like 10 and then cease adding more orbs. Is there a way to achieve this desired behavior? Thank you in advance for your assistance!