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

  Рет қаралды 12,847

Dors Coding School

Dors Coding School

Күн бұрын

Пікірлер: 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 Ай бұрын
the out of order steps confused me lol
@guchierrez
@guchierrez 2 жыл бұрын
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 жыл бұрын
Glad it helped!
@Spiriitu
@Spiriitu Жыл бұрын
im glad im not the only one that thought this
@BarcaFan12
@BarcaFan12 Жыл бұрын
@@DorsCodingSchool please have you done a video on "Revisiting Rock, Paper and Scissors"?
@Electric-Do-Stuff
@Electric-Do-Stuff Жыл бұрын
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 Жыл бұрын
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 ай бұрын
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 жыл бұрын
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 Жыл бұрын
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 ай бұрын
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 ай бұрын
Absolutely brilliant walkthrough
@unitedvoice1073
@unitedvoice1073 6 ай бұрын
Amazing and so simplified, thank you!!
@kauaiguy
@kauaiguy Жыл бұрын
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!
@mattweatherbean4prez
@mattweatherbean4prez 4 ай бұрын
This is an excellent walkthrough, thank you very much
@traezeeofor
@traezeeofor 2 жыл бұрын
Thanks for this. Great guide to complete my 1st The Odin "Project".
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
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 Жыл бұрын
OBRIGADA! i've been doing pretty well on the odin project but i would've never been able to do this by myself lol
@Thestorbob
@Thestorbob Жыл бұрын
Perfect, thank you! exactly what I needed
@doctorsocolinsky3116
@doctorsocolinsky3116 9 ай бұрын
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?
@beingold
@beingold 7 ай бұрын
she is the legend
@MacacoVictor
@MacacoVictor Жыл бұрын
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()
@whiskers08spot09
@whiskers08spot09 2 жыл бұрын
18:09 I'm a little confused here. Aren't you supposed to first put 'else'? or is that optional?
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
You can write else or not. It’s optional in this case ;)
@danielsantana5526
@danielsantana5526 2 ай бұрын
Você é brasileira?
@whiskers08spot09
@whiskers08spot09 2 жыл бұрын
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
@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
@Deatomized
@Deatomized Жыл бұрын
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. :)
@BarcaFan12
@BarcaFan12 2 жыл бұрын
@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 жыл бұрын
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!
@asiamahkorehglobal7782
@asiamahkorehglobal7782 2 жыл бұрын
Thank you very much
@ashalouis8667
@ashalouis8667 Жыл бұрын
Thanks. God bless!!!
@DorsCodingSchool
@DorsCodingSchool Жыл бұрын
You're welcome!
@stefaniagrigore8162
@stefaniagrigore8162 Жыл бұрын
what is the app she uses at the end to push all her work?
@DorsCodingSchool
@DorsCodingSchool Жыл бұрын
Sublime merge
@stefaniagrigore8162
@stefaniagrigore8162 Жыл бұрын
@@DorsCodingSchool thank you
@Stephen_Muiru26
@Stephen_Muiru26 Жыл бұрын
hello! awesome video. But how do i push to my github. Im having a difficult time doing so. Thank you
@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?
@user-bm8uu5eg5y
@user-bm8uu5eg5y 2 жыл бұрын
thank you for video.I've got question can you sing?
@DorsCodingSchool
@DorsCodingSchool 2 жыл бұрын
You're welcome!
@kecac4408
@kecac4408 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 жыл бұрын
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
@541ky
@541ky Ай бұрын
the out of order steps confused me lol
@nickrowe9431
@nickrowe9431 Жыл бұрын
The way she says winner tho 😂
@sallycar3114
@sallycar3114 Жыл бұрын
Anyone has the same video but the revisiting one, please?
@Ohall558
@Ohall558 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 жыл бұрын
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 жыл бұрын
You should check all the cases when you win or when the computer wins ;)
@oisterzenitzer9748
@oisterzenitzer9748 2 жыл бұрын
@@DorsCodingSchool Haven't thought of that. Thanks.
THE ODIN PROJECT: FOUNDATIONS - ETCH-A-SKETCH | PROJECT SOLUTION
37:34
Dors Coding School
Рет қаралды 10 М.
THE ODIN PROJECT: FOUNDATIONS - CALCULATOR | PROJECT SOLUTION
35:20
Dors Coding School
Рет қаралды 10 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Learn Javascript  Rock, Paper, Scissors
26:28
CodeWithRana
Рет қаралды 9 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 901 М.
The Odin Project - Revisiting Rock Paper Scissors
40:32
Boomers Playground
Рет қаралды 5 М.
Lecture 1 | Stanford CS193p 2023
1:11:04
Stanford CS193p
Рет қаралды 114 М.
Lecture 1: Course Overview + The Shell (2020)
48:17
Missing Semester
Рет қаралды 765 М.
programming projects that taught me how to code
9:49
isak
Рет қаралды 313 М.
Learn JavaScript Interactively in NEW freeCodeCamp.org Curriculum
53:26
freeCodeCamp.org
Рет қаралды 94 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН