+ 1
What's wrong in this code?
9 Respostas
+ 6
Your first letter leaves the a function with count of 2 instead of 1. B won't be matched as count is 1 not the required 0. Remove the ++ on count in the if statements and increment at the end of the function.
+ 5
You could do
var count = 0;
function a(){
var str = document.getElementById("input")
var p = document.getElementById("p")
p.innerHTML = "";
str.value = str.value.toUpperCase()
for(var a = 0; a < str.value.length; a++) {
if(str.value[a] == "A"){
p.innerHTML += ".-"
}
if(str.value[a] == "B"){
p.innerHTML += "-..."
}
}
}
+ 4
How is it supposed to work?
+ 3
When your if is processed your count++ happens whether the test was true or false as it is part of the decision process. The only time something doesn't get processed would be in this:
if (true || false)
False would not be checked because of the true. It could be expression with side effects like your count++ that will not happen.
if (false && true)
The true expression will not be checked.
+ 1
Thanks you John Wells and Thank you Toni Isotalo
+ 1
Hey John I hpe you be good today .Thanks for your explaining. I underestood
+ 1
https://code.sololearn.com/WvGTb8AoSWNL/?ref=app
Finally I made it by myself.Tanks but it's not complete yet
0
it's a morse
0
Just I don't underestand why??