+ 2
This is a morse code code. If I put ab it will alert .- -... and thats right. But if I put ba it will also put .- -...
Third question for this code. https://code.sololearn.com/W0hObMWqGlD0/?ref=app
5 odpowiedzi
+ 2
No. I used i.includes("a"), but you are using words.includes("a")
tempary variable i contains single characters extracted from words....
+ 2
Almost! Just if I put 2 letters in any order it shows .- -... twice and remember that I'm gonna add more letters later.
+ 1
If it is "ba" Or "ab" , both include a and b so both are true..
If you want in a row as input sequence, use loop and do it in sequence by splitiing input...
edit:
like this :
Lego in Motion
function morse() {
for(var i of words){
if(i.includes("a")) {
code=code+".- ";
};
if(i.includes("b")) {
code=code+"-... ";
};
}
alert(code);
}
+ 1
Oh yes! I didn't see that!
+ 1
YEEEEEEEES! THANK YOU!