22nd Jul 2018, 10:22 AM
Sina
Sina - avatar
9 Answers
22nd Jul 2018, 12:40 PM
John Wells
John Wells - avatar
+ 6
l1 is the list of characters to check against str.value[i]. indexOf returns -1 on failure to find the character or the index within the list so 0 or greater.
24th Jul 2018, 10:27 AM
John Wells
John Wells - avatar
+ 4
There are definitely things that try to convince you of that. However, eventually it makes sense and, when those types of new concepts attempt to confuse you, you go: oh..., yeah that makes sense. I just had one of those moments in Kotlin generics. About 5 minutes of what? Before, right! dawned. Just forge ahead you'll get there.
22nd Jul 2018, 4:27 PM
John Wells
John Wells - avatar
+ 4
it isn't legal to test a char against a list. If JS had an in operation like other languages, we could do: if(str.value[i] in l1). However, JS's in only verifies properties of the object.
24th Jul 2018, 10:38 AM
John Wells
John Wells - avatar
+ 1
variable names cannot be numbers, also you can't assign multiple values like you tried to do with multiple "=" symbols. rather i suggest making each variable an array of characters and checking if which one the current character belongs to
22nd Jul 2018, 11:45 AM
hinanawi
hinanawi - avatar
+ 1
Right on right on
24th Jul 2018, 10:23 AM
Sina
Sina - avatar
0
Every time that I read programming it gets harder😥
22nd Jul 2018, 4:17 PM
Sina
Sina - avatar
0
and why did you write if(l1.indexOf(str.value[i]) >= 0) I don't underestand that
24th Jul 2018, 10:25 AM
Sina
Sina - avatar
0
Can we write another if.. here e.g:if(str.value[i] == l1){score++}
24th Jul 2018, 10:31 AM
Sina
Sina - avatar