You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get an error saying game.check is not a function.
Background
Used material for fizzbuzz Javascript challenge as template.
The error came up as after I changed the naming of functions and values to fit my game.
I feel like my whole code is kind of a mess, I apologize in advance
Spec
describe('Game',()=>{letgame=newGameletPlayer1=('button1').valueletPlayer2=('button2').valuedescribe('Player1 wins',()=>{it('returns Player1 is the winner if Player1 enters "rock" and Player2 enters "scissors"',()=>{expect(game.check(Player1,Player2)).to.eql("Player1 is the winner!")})it('returns Player1 is the winner if Player1 enters "paper" and Player2 enters "rock"',()=>{expect(game.check(Player1,Player2)).to.eql("Player1 is the winner!")})it('returns Player1 is the winner if Player1 enters "scissors" and Player2 enters "paper"',()=>{expect(game.check(Player1,Player2)).to.eql("Player1 is the winner!")})})describe('Player2 wins',()=>{it('returns Player2 is the winner if Player2 enters "rock" and Player1 enters "scissors"',()=>{expect(game.check(Player1,Player2)).to.eql("Player2 is the winner!")})it('returns Player2 is the winner if Player2 enters "paper" and Player1 enters "rock"',()=>{expect(game.check(Player1,Player2)).to.eql("Player2 is the winner!")})it('returns Player2 is the winner if Player2 enters "scissors" and Player1 enters "paper"',()=>{expect(game.check(Player1,Player2)).to.eql("Player2 is the winner!")})})describe('Its a tie!',()=>{it('returns Its a tie! if Player1 == Player2',()=>{expect(game.check(Player1==Player2)).to.eql("Its a tie!")})})})
Implementation code
game.js
function Game() {
let Player1 = ('button1').value
let Player2 = ('button2').value
this.check = (Player1, Player2)
if (Player1 === Player2) {
return 'Its a tie!';
}
else if ((Player1 === "rock") && (Player2 === "scissors")) {
return 'Player1 is the winner!';
}
else if ((Player1 === "rock") && (Player2 === "paper")) {
return 'Player2 is the winner!';
}
else if ((Player1 === "paper") && (Player2 === "rock")) {
return 'Player1 is the winner!';
}
else if ((Player1 === "paper") && (Player2 === "scissors")) {
return 'Player2 is the winner!';
}
else if ((Player1 === "scissors") && (Player2 === "paper")) {
return 'Player1 is the winner!';
}
else if ((Player1 === "scissors") && (Player2 === "rock")) {
return 'Player2 is the winner!';
}
else {
return 'That is not the game pal, try "rock", "paper" or "scissors"';
}
}
application.js
it('clicking on the "Check" button', async () => {
await browser.fillIn("input[id='value1']", { with: "rock" })
await browser.clickOnButton("#button1")
await browser.fillIn("input[id='value2']", { with: "rock" })
await browser.clickOnButton("#button2")
await browser.clickOnButton("#button3")
let content = await browser.getContent("[id='display_answer']")
expect(content).to.eql('Its a tie!');
})
How did you try to solve the problem?
I think it has to do with the naming of different values, so I tried to figure out what and changed a bunch of them.
I have tried to google the error and on other RPS games, going through the material once again. I think it's more than one typo or wrong naming problem here so I found it hard to figure it out.
The text was updated successfully, but these errors were encountered:
Carrosen
changed the title
game.check is not a function. rock, paper scissors JS
Error while testing: game.check is not a function. rock, paper scissors JS
Apr 28, 2019
Carrosen
changed the title
Error while testing: game.check is not a function. rock, paper scissors JS
Error while testing: "TypeError: game.check is not a function" rock, paper scissors JS
Apr 28, 2019
Problem
I get an error saying game.check is not a function.
Background
Used material for fizzbuzz Javascript challenge as template.
The error came up as after I changed the naming of functions and values to fit my game.
I feel like my whole code is kind of a mess, I apologize in advance
Spec
Implementation code
game.js
application.js
How did you try to solve the problem?
I think it has to do with the naming of different values, so I tried to figure out what and changed a bunch of them.
I have tried to google the error and on other RPS games, going through the material once again. I think it's more than one typo or wrong naming problem here so I found it hard to figure it out.
The text was updated successfully, but these errors were encountered: