Hi I'm still new to javascript and I cannot understand why this if statement won't resolve
message is a variable string, take "!leve alc 35" as an example.
var leve = parseInt(message.split(' ')[2]);
var leves = function() {
if (Number(leve) < 50) {
[(message.split(' ')[1]).toUpperCase(),
round5(parseInt(message.split(' ')[2]))
]; // Getting the lvls in question
leves = leves.join("");
} else {
[(message.split(' ')[1]).toUpperCase(),
round2(parseInt(message.split(' ')[2]))
]; // Getting the lvls in question
leves = leves.join("");
}
};
I expect this code to identify if the value at the end of the String(message) is greater than 49 (50+), and if so use the round 2 formula instead of the round 5 formula. I know its the if statement at fault as each line runs fine separately and returns my expected value. I've compared my if statement to that on W3Schools and I don't believe I'm missing anything. I placed my if statement within a function and this stopped the initial error I received on loading the script, but I'm now questioning if this is the issue?
Aucun commentaire:
Enregistrer un commentaire