Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
doing the odin project: rock,paper,scissors and my output is always 'you draw'. someone please correct my code
Post Body

edit: now returning undefined

function computerPlay(){
const arr = ["Rock","Paper","Scissors"];
const random = Math.floor(Math.random()* arr.length);
return arr[random];

}

function playerPlay(){
let option = prompt("choose an action");
return option;
}

function playRound(ps,cs){
if (ps === cs){
return ('you draw!');
}else if ((ps === 'rock') && (cs === 'scissors')){
return("you win! rock beats scissors");
} else if (ps === 'rock' && cs === 'paper'){
return("you lose! paper  beats rock");
}else if(ps === 'paper' && cs === 'rock'){
return("you win! Paper beats scissors");
}else if(ps === 'paper' && cs === 'scissors'){
return("you lose! scissors beats paper");
}else if(ps === 'scissors' && cs === 'paper'){
return("you win! scissors beats paper");
}else if(ps === 'scissors' && cs === 'rock'){
return("you lose! rock beats scissors");
}

}

const ps=playerPlay();
const cs = computerPlay();
console.log(playRound(ps,cs));

Author
User Disabled
Account Strength
0%
Disabled 1 year ago
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,819
Link Karma
451
Comment Karma
1,268
Profile updated: 8 hours ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago