0
Help would be much appreciated
I want to write the names in the list and when the button is clicked I want to get a diffrent output for each name but a can't figure it out.I have been trying for at least 2 hours and nothing plz help https://code.sololearn.com/WlbNDEr7QD9X/?ref=app
8 Respuestas
0
Line 29: You check if the string x is equal to "Matematik" or if it is not a number. If you enter "Gjuhe shqipe" for example, it is not a number, so it prints "Shkruani nje nga lendet me siper qe te merni vitet perkatese." If you enter a number, it prints "undefined".
To be honest, I don't know what those sentences mean so I can't really tell exaxtly what you're expecting, but I hope that helps.
0
Sorry I had written it in my language chek it out now maybe you get it
0
Now when I write a subject I get an output for example when I write Math I get 10th class but when I write something else it doesnt change
0
Yes thanks, that helps!
So when you write "Maths" in the box, the first if (line 29) checks that the text is either not a number, or it is "Maths". Since it is, it changes to the text you wrote "10th class".
But what it then does is execute the second if (line 32). Because the text string is not a number, the if returns true. So that code is also executed. Then the text is changed to "7th class". That's why you get the same outcome each time.
0
Can you help me with thet😅
0
Yes of course! You can use a switch for this. See code;
https://code.sololearn.com/W79porxqB51x/?ref=app
0
I really appreciate your help man I know about the switch but couldn't think about it thank you again for your help
0
No problem!