0

How can you avoid repetition in js

I am working on an app that uses a database but it prints the person name from the database more than once(5 times) please help me guys

25th Dec 2019, 9:01 AM
Ifedayo Prince Oni
Ifedayo Prince Oni - avatar
9 Respuestas
+ 1
Can you write the code here please
25th Dec 2019, 9:02 AM
ycsvenom
ycsvenom - avatar
+ 1
Just copy it to the private or in comments like a text
25th Dec 2019, 9:27 AM
ycsvenom
ycsvenom - avatar
+ 1
Look if this is the code then there's two mistakes 1- in case help you forgot to type ":" in last of statement 2- in case date you forgot to add break;
25th Dec 2019, 9:48 AM
ycsvenom
ycsvenom - avatar
0
Make sure it's not inside a for loop or an event.
25th Dec 2019, 9:16 AM
SoundInfinity
SoundInfinity - avatar
0
Unable to post the code
25th Dec 2019, 9:25 AM
Ifedayo Prince Oni
Ifedayo Prince Oni - avatar
0
It's not in a for loop, it's in a switch loop
25th Dec 2019, 9:27 AM
Ifedayo Prince Oni
Ifedayo Prince Oni - avatar
0
Let me be straight, its meant to get users input and obey var sl = prompt("Command: "); switch (sl) { case "help" alert("about, date"); break; case "date": var date = new Date() alert(date); case "about": alert("Version 1.8"); break; default: alert("No such command") break; } This is all so far
25th Dec 2019, 9:41 AM
Ifedayo Prince Oni
Ifedayo Prince Oni - avatar
0
Thanks, Works perfectly
25th Dec 2019, 9:50 AM
Ifedayo Prince Oni
Ifedayo Prince Oni - avatar
0
it could be that its in a loop.. i think thats the only possible explanation
25th Dec 2019, 8:11 PM
Ngene Tboy