Тёмный

Build JavaScript ROCK PAPER SCISSORS in 18 minutes! 👊 

Bro Code
Подписаться 2,2 млн
Просмотров 33 тыс.
50% 1

Опубликовано:

 

28 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 62   
@BroCodez
@BroCodez 9 месяцев назад
// ROCK PAPER SCISSORS const choices = ["rock", "paper", "scissors"]; const playerDisplay = document.getElementById("playerDisplay"); const computerDisplay = document.getElementById("computerDisplay"); const resultDisplay = document.getElementById("resultDisplay"); const playerScoreDisplay = document.getElementById("playerScoreDisplay"); const computerScoreDisplay = document.getElementById("computerScoreDisplay"); let playerScore = 0; let computerScore = 0; function playGame(playerChoice){ const computerChoice = choices[Math.floor(Math.random() * 3)]; let result = ""; if(playerChoice === computerChoice){ result = "IT'S A TIE!"; } else{ switch(playerChoice){ case "rock": result = (computerChoice === "scissors") ? "YOU WIN!" : "YOU LOSE!"; break; case "paper": result = (computerChoice === "rock") ? "YOU WIN!" : "YOU LOSE!"; break; case "scissors": result = (computerChoice === "paper") ? "YOU WIN!" : "YOU LOSE!"; break; } } playerDisplay.textContent = `PLAYER: ${playerChoice}`; computerDisplay.textContent = `Computer: ${computerChoice}`; resultDisplay.textContent = result; resultDisplay.classList.remove("greenText", "redText"); switch(result){ case "YOU WIN!": resultDisplay.classList.add("greenText"); playerScore++; playerScoreDisplay.textContent = playerScore; break; case "YOU LOSE!": resultDisplay.classList.add("redText"); computerScore++; computerScoreDisplay.textContent = computerScore; break; } } Document Rock - Paper - Scissors 👊 ✋ ✌ PLAYER: COMPUTER: Player Score: 0 Computer Score: 0 body{ font-family: Arial, sans-serif; font-weight: bold; margin: 0; display: flex; flex-direction: column; align-items: center; } h1{ font-size: 3.5rem; color: hsl(0, 0%, 20%); } .choices{ margin-bottom: 30px; } .choices button{ font-size: 7.5rem; min-width: 160px; margin: 0 10px; border-radius: 250px; background-color: hsl(200, 100%, 50%); cursor: pointer; transition: background-color 0.5s ease; } .choices button:hover{ background-color: hsl(200, 100%, 70%); } #playerDisplay, #computerDisplay{ font-size: 2.5rem; } #resultDisplay{ font-size: 5rem; margin: 30px 0; } .scoreDisplay{ font-size: 2rem; } .greenText, #playerScoreDisplay{ color: hsl(130, 84%, 54%); } .redText, #computerScoreDisplay{ color: hsl(0, 84%, 60%); }
@gpu_governor
@gpu_governor 9 месяцев назад
@BroCodez why are you creating a new javascript playlist, will the old one be deleted ?
@mahithmahi9446
@mahithmahi9446 7 месяцев назад
Can you send full code ......
@shieldanime6968
@shieldanime6968 7 месяцев назад
You are a lifesaver brocodez 💪💪💪🎉🎊🎉🎊🎉🎆🎇🎆🎇🎆🎇🙏🙏🙏
@IanAdaque
@IanAdaque 4 месяца назад
Bro how about if your code said choice is not defined
@LOLFUNNYTIKTOKS
@LOLFUNNYTIKTOKS 29 дней назад
I followed this exactly but mine keeps being a tie
@doronfeldman5152
@doronfeldman5152 9 месяцев назад
Hey bro, are you going to do a node.js course in the future?
@opiirix3302
@opiirix3302 9 месяцев назад
How did you learn front-end development? I'm just having trouble finding a beneficial course for me; however, some videos like your HTML/CSS/JavaScript or the CS50web dev course have been really helpful for me
@jobnacorconcepcionabad6037
@jobnacorconcepcionabad6037 8 месяцев назад
I recommendo you the Odin Project
@Birandoo
@Birandoo 6 месяцев назад
Check out "The Odin Project". I highly recommend it. I'm taking it now. Online, free and good for what you will need for getting a job later.
@Adithyarmenon198
@Adithyarmenon198 9 месяцев назад
Nice Program I am also doing almost similar ones😃
@festussabu
@festussabu 9 месяцев назад
hey can you do a video about how intersection observer works in react..
@gatenetsetgo....7012
@gatenetsetgo....7012 9 месяцев назад
Please,make full tutorial from basic to advance
@ArtistikNoName
@ArtistikNoName 9 месяцев назад
can u make a full course of lua, please?
@BruceWayne-f7u
@BruceWayne-f7u 3 месяца назад
This is so easy
@youngtrouble00
@youngtrouble00 9 месяцев назад
How didu make that website
@maxxernB
@maxxernB Месяц назад
11:19 how did you select code and backspace all of it one space backwards?
@johnnyklash5883
@johnnyklash5883 24 дня назад
hey mate, " ctrl + [ " is the shortcut in VS code or " ctrl + ] " to move it forward.
@phantriviethoang
@phantriviethoang 11 дней назад
Another way is to use Tab and Shift + Tab.
@Nigelsworld2015
@Nigelsworld2015 Месяц назад
what is the code
@HKkinner
@HKkinner 9 месяцев назад
pls pin me i am 7th
@izharahmed1809
@izharahmed1809 10 дней назад
which app he used for coding
@UNKNOWN_1005-o5A
@UNKNOWN_1005-o5A 8 месяцев назад
it aint working
@l-fitness3590
@l-fitness3590 8 месяцев назад
Did you find the solution
@UNKNOWN_1005-o5A
@UNKNOWN_1005-o5A 7 месяцев назад
@@l-fitness3590 no
@-ASTROMAGIC
@-ASTROMAGIC 6 месяцев назад
you need to to return the result at the end of the playGame function and it should work. not really sure why his doesn't produce an error
@-ASTROMAGIC
@-ASTROMAGIC 6 месяцев назад
his switch cases are also incomplete and will produce bugs, but it's nothing that can't be fixed by going on stackoverflow.
@0nullBit
@0nullBit 6 месяцев назад
@@-ASTROMAGIC what why does the play game need to return anything. Also the switch should work perfectly fine….
@hasnainmalik8982
@hasnainmalik8982 9 месяцев назад
Hey bro I am your permanent subscriber from India if nobody is watching your video or you are getting only one view I am sure that I will be that one viewer watching your videoa
@sadboy-xx6gh
@sadboy-xx6gh 9 месяцев назад
I'm from India too and I've been watching his videos for more than a year. I've seen some video tutorials more than 10 times. For some of them going for as long as 12 hours.
@mosshead_vinsmoke
@mosshead_vinsmoke 5 месяцев назад
@@sadboy-xx6gh same here, Indian channel are good but they are boring but my Man here knows how to teach in a fun whimsical way + he is the get to guy when you wanna review some concepts or topics
@OrionsFactFactory
@OrionsFactFactory 9 месяцев назад
I just wanna say you are every Computer Science students hero man❤
@oybekabdumalikov2763
@oybekabdumalikov2763 9 месяцев назад
Coding bootcamps hate you and also their businesses are in minus 😂
@gitapaneru3829
@gitapaneru3829 12 дней назад
can you give the the images of rock paper and scissor please . I cant find a good one in the google
@cryptoptinvestor384
@cryptoptinvestor384 7 месяцев назад
For me to add some emojis "Windows Key + ." Win+.
@jiyoungkim9258
@jiyoungkim9258 9 месяцев назад
you're my life saver!
@hma201
@hma201 10 дней назад
Why did we timed math.rendom by 3 ? (Mathe.rendom()*3)
@Randomly_selected212
@Randomly_selected212 7 дней назад
because there are 3 values which is rock paper and scissors. And 3 is to put a limit to 3 because if he didn't it would want to randomize to infinity or not run because it is trying to find a number we didn't set.
@hma201
@hma201 7 дней назад
@@Randomly_selected212 thanks
@AvidAfrican
@AvidAfrican 9 месяцев назад
Bro code came in 2024 loaded... i'm following you...
@did_someoneknow
@did_someoneknow 4 месяца назад
Why my code is not working?
@GnomeBobMC
@GnomeBobMC 9 месяцев назад
First 🤓
@BroCodez
@BroCodez 9 месяцев назад
You win! 🎊
@GnomeBobMC
@GnomeBobMC 9 месяцев назад
@@BroCodez No way this legend actually responded 🥳🎉
@silviocorrea25
@silviocorrea25 9 месяцев назад
Great content
@l-fitness3590
@l-fitness3590 8 месяцев назад
For anyone having problems put the script link before the last body tag not in the head section
@hiya1399
@hiya1399 4 месяца назад
THANK YOU!!! I've been working on this for hours and couldn't figure out why it wasn't working.
@l-fitness3590
@l-fitness3590 4 месяца назад
@@hiya1399 been a while since I put this comment but you can put it in the head but add defer
@lucasquinncreations
@lucasquinncreations 3 месяца назад
Thank you! Why does having the script in the html header break functions like this?
@l-fitness3590
@l-fitness3590 3 месяца назад
@@lucasquinncreations I might be incorrect so take what I say with a pinch of salt but by adding defer your letting the html load first
@lucasquinncreations
@lucasquinncreations 3 месяца назад
@@l-fitness3590 I see it. Perhaps a case of needing the text fields loaded first before changing them.
Далее
Build a JavaScript IMAGE SLIDER in 15 minutes! 🖼️
15:49
Build this JS STOPWATCH in 18 minutes! ⏱
18:06
Просмотров 27 тыс.
Meni yerga urdingda
00:20
Просмотров 484 тыс.
Офицер, я всё объясню
01:00
Просмотров 3,7 млн
Learn Javascript  Rock, Paper, Scissors
26:28
Просмотров 9 тыс.
My 10 “Clean” Code Principles (Start These Now)
15:12
What are JavaScript PROMISES? 🤞
12:37
Просмотров 65 тыс.
Build this JS calculator in 15 minutes! 🖩
15:20
Просмотров 570 тыс.
Coding Was HARD Until I Learned These 5 Things...
8:34
Code Flappy Bird in Java
54:02
Просмотров 102 тыс.
Build this React To-Do List app in 20 minutes! ☝
22:35
Learn JavaScript With This ONE Project!
1:10:26
Просмотров 727 тыс.