THE ODIN PROJECT: FOUNDATIONS - ROCK PAPER SCISSORS | PROJECT SOLUTION

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ม.ค. 2025

ความคิดเห็น • 72

  • @DorsCodingSchool
    @DorsCodingSchool  ปีที่แล้ว

    👨‍💻 Learn How to Code with Private Classes - www.dorscodingschool.com/coachingplans
    ❓Having a hard time with CS50, FreeCodeCamp or Odin Project? Practice with our exclusive free coding platform: www.codingdors.com/
    🎯 Are You A Coding Expert? Take Our Free Quiz and Find Out - www.dorscodingschool.com/quiz

    • @541ky
      @541ky 2 หลายเดือนก่อน

      the out of order steps confused me lol

  • @guchierrez
    @guchierrez 2 ปีที่แล้ว +60

    thanks for this guide.
    TOPs javascript introduction was $hit, literally impossible to solve this without external help. there was literally almost no coding practice before this, only a bunch of useless text walls

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว +4

      Glad it helped!

    • @lillyadamo
      @lillyadamo ปีที่แล้ว +29

      im glad im not the only one that thought this

    • @BarcaFan12
      @BarcaFan12 ปีที่แล้ว +2

      @@DorsCodingSchool please have you done a video on "Revisiting Rock, Paper and Scissors"?

    • @Electric-Do-Stuff
      @Electric-Do-Stuff ปีที่แล้ว +6

      I know rIght! Luckily I had some JS knowledge going in, but for someone completely new to JS it's a ridiculous task. You're being asked to create arrays and use loops before they have even taught anything about arrays or loops. Not to mention asking you to create a case-insensitive input when they haven't covered string methods in any shape or form. Seems very backward to me.

    • @Jaimelapoesie
      @Jaimelapoesie ปีที่แล้ว +9

      I thought I was just shit as coding until I read this comment... what a crazy first task. I'm probably going back to FreeCodeCamp or CodeAcademy at this point.

  • @Iloveprogrammiiing
    @Iloveprogrammiiing 10 หลายเดือนก่อน +2

    Thank you so Much Giovanna, this is the most simplest breakdown I've seen from all the other solutions I was working with before

  • @jenniferguneratne2210
    @jenniferguneratne2210 2 ปีที่แล้ว +8

    Thank you!! I was struggling with announcing the score at the end and this helped me clean up my code to make it work. One thing I noticed: the score had a tendency to increment one point for the player on a tied round, resulting in an inaccurate end result. I added a line to prevent the code from incrementing for either player if the round was drawn. I really appreciate the time you took to make this video!

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว

      We are glad to hear that! Thank you for your feedback, we will fix it :)

    • @gavincain9837
      @gavincain9837 ปีที่แล้ว +1

      I have that same problem, how did you do that? The new line I mean

    • @Iloveprogrammiiing
      @Iloveprogrammiiing 10 หลายเดือนก่อน

      ​​@@gavincain9837this is how I did it:
      else if(checkWinner(playerSelection, computerSelection) == "Tie") {
      scorePlayer++;scoreComputer++;
      }

    • @Iloveprogrammiiing
      @Iloveprogrammiiing 10 หลายเดือนก่อน +1

      And then I added a line of code console logging the scorePlayer and the scoreComputer to double check if it was working properly

  • @girlintheworld8433
    @girlintheworld8433 6 หลายเดือนก่อน +2

    Absolutely brilliant walkthrough

  • @kauaiguy
    @kauaiguy ปีที่แล้ว +3

    Thank you so much for this easy to follow along video! I was stuck on this assignment on TOP and I was easily able to follow and understand what you were doing. Thank you!

  • @unitedvoice1073
    @unitedvoice1073 6 หลายเดือนก่อน +1

    Amazing and so simplified, thank you!!

  • @mattweatherbean4prez
    @mattweatherbean4prez 4 หลายเดือนก่อน

    This is an excellent walkthrough, thank you very much

  • @traezeeofor
    @traezeeofor 2 ปีที่แล้ว +4

    Thanks for this. Great guide to complete my 1st The Odin "Project".

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว +1

      Glad to hear that! We will be posting more videos about The Odin Project :)
      By the way, we have a Telegram Group to help people learn how to code and where you can connect with learners from all over the world. Over there you can ask any question about programming and you can easily get your questions answered within 24 hours.
      Besides that, you will have access to our membership with more than 400 problems made by us to ease your learning curve and 1 hour of group coaching every month!
      Check www.dorscodingschool.com/products

    • @girlintheworld8433
      @girlintheworld8433 6 หลายเดือนก่อน

      @@DorsCodingSchool oh wow! What a great resource!

  • @patitatitatitatitona
    @patitatitatitatitona ปีที่แล้ว +1

    OBRIGADA! i've been doing pretty well on the odin project but i would've never been able to do this by myself lol

  • @whiskers08spot09
    @whiskers08spot09 2 ปีที่แล้ว +1

    18:09
    I'm a little confused here. Aren't you supposed to first put 'else'? or is that optional?

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว +1

      You can write else or not. It’s optional in this case ;)

  • @Thestorbob
    @Thestorbob ปีที่แล้ว

    Perfect, thank you! exactly what I needed

  • @doctorsocolinsky3116
    @doctorsocolinsky3116 9 หลายเดือนก่อน +2

    Hello, thanks for the video, but in the function getPlayerChoice, I do exactly the same as you did there, but the promp never shows, instead the game is played automatically 5 times, with all loses, any help with that?

  • @BarcaFan12
    @BarcaFan12 2 ปีที่แล้ว +1

    @6:50, my console keeps saying "Maths Not defined"
    And My code is exactly like yours;
    Function getComputerChoice() {
    Const choice = options [math.floor(math.random() * options.length)];
    Console.log(choice);
    }
    getcomputerchoice () ;
    But my console keeps saying "Uncaught ReferenceError: math is not defined".

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว +2

      You probably should use Math with capital M. If you want, you can join our Free Discord Community: www.dorscodingschool.com/discord

    • @BarcaFan12
      @BarcaFan12 2 ปีที่แล้ว

      @@DorsCodingSchool Thanks!

  • @MacacoVictor
    @MacacoVictor ปีที่แล้ว +2

    Giovanna, eu estava com dúvida nesse código e após assistir o seu vídeo eu consegui finalizar o meu. Porém, ao inserir a função game e o loop, meu console mostra que o playerSelection não foi definido, mas se eu tiro a função, o jogo funciona, você poderia me ajudar??
    const pick = ["rock", "paper", "scissors"]
    function getComputerChoice(){
    const choice = pick[Math.floor(Math.random() * pick.length)];
    return choice;
    }
    function checkWinner(){
    if(playerSelection == computerSelection){
    return "Tie";
    }else if (playerSelection == "rock" && computerSelection == "scissors" ||
    playerSelection == "paper" && computerSelection == "rock" ||
    playerSelection == "scissors" && computerSelection == "paper"){
    return "Player";
    } else{
    return "Computer";
    }
    }
    function playRound(playerSelection, computerSelection){
    const result = checkWinner(playerSelection, computerSelection);
    if (result == "Tie"){
    return "It's a Tie!"
    } else if(result == "Player"){
    return `You Win! ${playerSelection} beats ${computerSelection}`
    } else if (result == "Computer"){
    return `You Lose! ${computerSelection} beats ${playerSelection}`
    }
    }
    function getPlayerChoice(){
    let validatedInput = false;
    while(validatedInput == false){
    const choice = prompt ("Rock Paper Scissors");
    if(choice == null){
    continue;
    }
    const choiceInLower = choice.toLowerCase();
    if(pick.includes(choiceInLower)){
    validatedInput = true;
    return choiceInLower;
    }
    }
    }
    function game(){
    let scorePlayer = 0
    let scoreComputer = 0
    for(let i = 0; i < 5; i++){
    const playerSelection = getPlayerChoice();
    const computerSelection = getComputerChoice();
    console.log(playRound(playerSelection, computerSelection))
    console.log("-----")
    if (checkWinner(playerSelection, computerSelection) == "Player"){
    scorePlayer++;
    }
    else if (checkWinner(playerSelection, computerSelection) == "Computer"){
    scoreComputer++;
    }
    if(scorePlayer>scoreComputer){
    console.log("Player wins!")
    } else if(scoreComputer>scorePlayer){
    console.log("PC wins")
    }
    else {
    console.log("Tie again")
    }
    }
    }
    game()

  • @beingold
    @beingold 7 หลายเดือนก่อน +1

    she is the legend

  • @Deatomized
    @Deatomized ปีที่แล้ว +2

    Hi! I have to thank you for this guide. As somebody said here before me, as total beginner it was really frustrating to get this thing going from scratch without ever trying to write code in JS. html and css at the beginning was quite fast to learn, only flex box took me couple of days to get a grasp on. (gamify helped a lot - flexfrog! :) ) but I'd like to ask about one thing. PlayRound function is called how, in the for loop? by the console? It's the only thing that's bugging my head. I thought, that I have to call the function inside the for loop to make it run. Can you, or somebody please explain? thanks a lot!

    • @DorsCodingSchool
      @DorsCodingSchool  ปีที่แล้ว

      We call playRound function inside the game function. If you see we are calling this function to display in the console.log :)

    • @Deatomized
      @Deatomized ปีที่แล้ว

      @@DorsCodingSchool thanks for reply. I didnt know, thats enough. :)

  • @gavincain9837
    @gavincain9837 ปีที่แล้ว

    It all works fine except that the prompt doesn't allow anything to show in the console. I have to comment out the function then open the page with live server , then go Back and uncomment the function. Is there a way around this? I tried settimeout but it didn't work either

  • @whiskers08spot09
    @whiskers08spot09 2 ปีที่แล้ว +3

    Is there a part 2 for the revisiting rock paper scissors?

    • @sallycar3114
      @sallycar3114 ปีที่แล้ว

      did you get the revisiting video?? did you do it pls??

    • @whiskers08spot09
      @whiskers08spot09 ปีที่แล้ว

      @@sallycar3114 i did not, I ended up switching to doing the Codecademy front end course, way better. Had to pay $150 tho

  • @Stephen_Muiru26
    @Stephen_Muiru26 ปีที่แล้ว

    hello! awesome video. But how do i push to my github. Im having a difficult time doing so. Thank you

  • @stefaniagrigore8162
    @stefaniagrigore8162 ปีที่แล้ว +1

    what is the app she uses at the end to push all her work?

  • @asiamahkorehglobal7782
    @asiamahkorehglobal7782 2 ปีที่แล้ว +1

    Thank you very much

  • @ashalouis8667
    @ashalouis8667 2 ปีที่แล้ว +1

    Thanks. God bless!!!

  • @anitahemmings8785
    @anitahemmings8785 ปีที่แล้ว

    after trying to put prompt and doing rpm install prompt-sync I get the error : prompt is not defined what do I do?

    • @doctorsocolinsky3116
      @doctorsocolinsky3116 9 หลายเดือนก่อน

      I have the same issue, I know your comment is from long ago but did you find any solution?

  • @danielsantana5526
    @danielsantana5526 2 หลายเดือนก่อน +1

    Você é brasileira?

  • @kecac4408
    @kecac4408 2 ปีที่แล้ว +2

    I have a problem where the game function is asking for twice as much input and only the second input is taken in as input.
    function game() {
    for ( let i = 0; i < 5; i++) {
    const playerSelection = getPlayerChoice();
    const computerSelection = getComputerChoice();
    console.log(playRound(playerSelection, computerSelection));
    }
    }
    Same as yours.
    I tried commenting out the const`s and resulted in error, once i commented out the console.log it just asked 5 times for input. The problem is visible but why is the code running like this?

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว +1

      We’d love to help you more. Did you know you can join our Free Discord Group and get help from me and from people around the world that are also learning how to code? dorscodingschool.com/discord

  • @user-bm8uu5eg5y
    @user-bm8uu5eg5y 2 ปีที่แล้ว +1

    thank you for video.I've got question can you sing?

  • @nickrowe9431
    @nickrowe9431 ปีที่แล้ว

    The way she says winner tho 😂

  • @541ky
    @541ky 2 หลายเดือนก่อน

    the out of order steps confused me lol

  • @sallycar3114
    @sallycar3114 ปีที่แล้ว +1

    Anyone has the same video but the revisiting one, please?

  • @Ohall558
    @Ohall558 ปีที่แล้ว +1

    I wrote the code exactly as you did in the video for getPlayerChoice function, but when the page loads the prompt and you enter a choice, the console doesn't log anything and it just restarts the loop? Am I writing something wrong here?
    function getPlayerChoice(){
    let validatedInput = false;
    while(validatedInput == false){
    const choice = prompt("Rock Paper Scissors");
    if (choice == null){
    continue;
    }
    const choiceLowerCase = choice.toLowerCase();
    if (options.includes(choiceLowerCase)){
    validatedInput = true;
    return choiceLowerCase;
    }
    }
    }

    • @DorsCodingSchool
      @DorsCodingSchool  ปีที่แล้ว +1

      Did you hard reload your page? You should do ctrl + shift + r.
      This part should be working, you can check our solution on www.dorscodingschool.com/ebook

    • @Ohall558
      @Ohall558 ปีที่แล้ว +1

      @@DorsCodingSchool I just figured out the issue this morning. I had capitalized the array items so the options.included was never going to work. But thank you, this video saved me a ton of frustration!

  • @oisterzenitzer9748
    @oisterzenitzer9748 2 ปีที่แล้ว +1

    Hi. When i play the game, it's throwing a logic error. If i chose rock and computer chose paper, it should console log that you lose! paper beats rock! But it is doing the opposite of that. why is that?
    My code is almost the same as yours. Here is it:
    const options = ["rock", "paper", "scissor"];
    function getComputerChoice() {
    const choice = options[Math.floor(Math.random() * options.length)];
    return choice;
    }
    function checkWinner(playerSelection, computerSelection) {
    if (playerSelection == computerSelection) {
    return "It's a tie";
    } else if (
    (playerSelection == "rock" && computerSelection == "scissor") ||
    (playerSelection == "scissor" && computerSelection == "paper") ||
    (playerSelection == "paper" && computerSelection == "rock")
    ) {
    return "Player";
    } else {
    return "Computer";
    }
    }
    function playRound(playerSelection, computerSelection) {
    const result = checkWinner(playerSelection, computerSelection);
    if (result == "It's a tie") {
    return "It's a tie!";
    } else if (result == "Player") {
    return `You win! ${playerSelection} beats ${computerSelection}`
    } else {
    return `You lose! ${computerSelection} beats ${playerSelection}`
    }
    }
    function getPlayerChoice() {
    let validInput = false;
    while(validInput == false) {
    const choice = prompt("Rock Paper Scissor");
    if (choice == null) {
    continue;
    }
    const choiceInLower = choice.toLowerCase();
    if(choice.includes(choiceInLower)) {
    validInput = true;
    return choiceInLower;
    }
    }
    }
    function game() {
    let playerScore = 0;
    let computerScore = 0;
    for( let i = 0; i < 5; i++) {
    const playerSelection = getPlayerChoice();
    const computerSelection = getComputerChoice();
    console.log(playRound(computerSelection, playerSelection));
    if (checkWinner(playerSelection, computerSelection) == "Player") {
    playerScore++;
    }
    else if (checkWinner(playerSelection, computerSelection) == "Computer") {
    computerScore++;
    }
    }
    console.log("Game over!")
    if (playerScore > computerScore) {
    console.log("Player was the winner!");
    } else if (playerScore < computerScore) {
    console.log("Computer was the winner!");
    } else {
    console.log("We have a tie!");
    }
    }
    game()
    Thanks in advance to anyone who is willing to help 😁

    • @DorsCodingSchool
      @DorsCodingSchool  2 ปีที่แล้ว +1

      You should check all the cases when you win or when the computer wins ;)

    • @oisterzenitzer9748
      @oisterzenitzer9748 2 ปีที่แล้ว

      @@DorsCodingSchool Haven't thought of that. Thanks.