+ 2

Need help on my code

I need help on my code this is the project you will get the details inside just test it and fix the glitch by copying it and changing the code DONT CHANGE THE DESIGN also later I'm going to add a win screen. https://code.sololearn.com/Ww5byVR5LZhz I won't tell you what error is it because it is easy to find. First you have to play the game.

31st Mar 2017, 2:04 PM
koder
koder  - avatar
9 Answers
+ 11
https://code.sololearn.com/Wc7cm2rkRXVp/?ref=app I only changed the confirm function and now it works. function confirm() { var p2 var inp = ($('textarea').val()).toLowerCase() var c = null var x = 0 var xb = 0 var test = []; for(; x <= word.length; x++) { if (!c) { xb++ if (inp == word[x]) { test.push(xb - 1); } } } if (test.length > 0) { for (i = 0; i < test.length; i++) { console.log(test) display[test[i]] = word[test[i]] writeOnScreen() $('#in').text("") document.getElementById('right').play() checkIfWon() } } else if (test.length == 0) { attempts-=1 if (attempts == 1) { p2 = 'attempt' } else { p2 = 'attempts' } $('.ats').text(attempts + ' ' + p2) document.getElementById('wrong').play() checkIfLose() drawVisual() } }
2nd Apr 2017, 1:13 PM
The Coding Sloth
The Coding Sloth - avatar
+ 10
the problem is capitalized letters. In your confirm function use this as value for inp: var inp = ($('textarea').val()).toLowerCase()
31st Mar 2017, 2:51 PM
The Coding Sloth
The Coding Sloth - avatar
+ 10
then what is the error?
1st Apr 2017, 2:11 PM
The Coding Sloth
The Coding Sloth - avatar
+ 10
Just two last things: I accidentally left a console.log in your confirm method, you might want to remove that. When someone presses the button you could clear the input area, this way that someone doesn't have to remove the letter.
3rd Apr 2017, 4:14 PM
The Coding Sloth
The Coding Sloth - avatar
+ 2
Thanks now I can publish it P.S i gave credit for u helping me
2nd Apr 2017, 6:13 PM
koder
koder  - avatar
+ 1
forgot to put in the link
31st Mar 2017, 1:39 PM
koder
koder  - avatar
+ 1
thats not the error! thanks for suggesting that anyway, i forgot some people will use uppercase letters
1st Apr 2017, 2:10 PM
koder
koder  - avatar
+ 1
you cant figure it out? have you've tried to win the game yet? i put in debug so it tells u what the wordd is so u can help me. the error is when a word has 2 of the same letter u cant put in 2 u can only put 1 because the code detected the right letter so it stops the loop. when u gp do it again it cdetects the correct letter at the same spots and stops the loop.
2nd Apr 2017, 12:45 PM
koder
koder  - avatar
0
Which code?
31st Mar 2017, 4:49 AM
Luca Garrera