I am trying to create a string with two strings "name1" and "name2" in such a way that it always begins with the longer string. For this purpose, I am using the following code:
if (name1.length > name2.length)
str = name1 + "kills" + name2;
else
str = name2 + "kills" + name1;
In this code, the 'if' case works even when the condition is false. I have tried adding braces and even changed the condition to " name1.length-name2.length>0 ". But still, the code does not work. What shall I do?
Aucun commentaire:
Enregistrer un commentaire