Exercise 1 - Guess the Number | JavaScript Tutorial in Hindi #22

  Рет қаралды 288,371

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 866
@CodeWithHarry
@CodeWithHarry 2 жыл бұрын
Happy Independence Day everyone :)
@chandanprajapati9704
@chandanprajapati9704 2 жыл бұрын
Same to you harry bhai.. 🇮🇳 ❤️
@shaktiexcellentchannel7834
@shaktiexcellentchannel7834 2 жыл бұрын
Mera comments high light Kijiji comments box pe please Bhai 🎉🎉🎉🇮🇳💐💐🙏🙏🙏💐🙏💐💐💐💐🇮🇳🇮🇳🇮🇳🇮🇳🇮🇳🇮🇳
@rahilkarkar7727
@rahilkarkar7727 2 жыл бұрын
Happy independence day Harry bhai
@MJGameZone
@MJGameZone 2 жыл бұрын
Same 2 u bro...
@code_with_ayush
@code_with_ayush 2 жыл бұрын
Same to you🇮🇳🇮🇳
@ankursharma1822
@ankursharma1822 11 ай бұрын
let score = 0; let r = Math.ceil(Math.random()); console.log(r) for(let i = 1;i userInput){ score+=1; } else if(r < userInput){ score+=1; } else{ break; } } let res = (100 - score); console.log(res);
@CodeWithHarry
@CodeWithHarry Жыл бұрын
Code Backup Repository: github.com/CodeWithHarry/ultimate-js-course-youtube
@yashvantjankar8905
@yashvantjankar8905 8 ай бұрын
Let num = Math.round((Math.random)*100); Console.log(num); Random number is done
@sobansaleem3492
@sobansaleem3492 7 ай бұрын
@@user-kq5up7fy2u what's the +1 for?
@shivpathak5897
@shivpathak5897 Жыл бұрын
let n=Math.floor(Math.random()*100) let m=prompt("enter the nuber") let c=0 while(m!=n){ if(m>n){ m=prompt("enter lesser number") c++ } if(m
@Shekhuguruji
@Shekhuguruji 5 ай бұрын
there is a flaw, your code will generate a random number between 0 to 99, not 1 to 100
@kashif2niazi
@kashif2niazi 5 ай бұрын
@@Shekhuguruji let n=Math.floor(Math.random()*99)+1
@Shekhuguruji
@Shekhuguruji 5 ай бұрын
@@kashif2niazi yep this is correct now
@nitubhuwalka9620
@nitubhuwalka9620 Жыл бұрын
I did the same program in python from your course by myself and now this time through javascript course...... Thank you harry
@Shakeel7573
@Shakeel7573 Жыл бұрын
Harry you are a best IT teacher. Your method of explanation is not only good but also at next level. I am Shakeel from Punjab Pakistan.
@learndigitalskills8932
@learndigitalskills8932 2 жыл бұрын
Bro! You are doing great, I'm wartching 4 videos of this playlist daily, I did this exercise today, You are giving such a premium course in free. Thank you
@samirbante8554
@samirbante8554 Жыл бұрын
Sikh gaya kya javascript
@learndigitalskills8932
@learndigitalskills8932 Жыл бұрын
@@samirbante8554 yes
@tirthsorthiya6320
@tirthsorthiya6320 2 жыл бұрын
There is magic in harry bhai's words that I started writing the code without seeing time and when I finished I saw it was 1am at night. It is because of harry Bhai Harry bhai is really great.
@thomasshelby447
@thomasshelby447 Жыл бұрын
let a = Math.random() * 100 a = Math.round(a) let b = prompt("guess the number") let chances = 1 while (a != b) { console.log("the number is ", a < b ? "less than " + b : "greater than " + b) b = prompt("guess the number again") chances += 1 } console.log("you guessed it right") console.log("you took "+chances+" chances to guess the right number")
@Richhera
@Richhera 7 ай бұрын
Bhai tera comment try karke muje lagra hai abhi muje kuch nahi aya hai
@utkarshanikam287
@utkarshanikam287 Ай бұрын
😅😅😂​@@Richhera
@hrithik5220
@hrithik5220 2 жыл бұрын
Legend Harry Bhai🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 Aapka complete 1 video Wala hrml css course ne aag laga diya .thankyou so much
@pg_piyush
@pg_piyush 2 жыл бұрын
Bhaiya... I am going to start my BTECH CSE journey Soon Plz make a video.. on how a students should start it learning with your courses Since you had made so many courses and playlist. Plz guide ‼️
@mrperfect6700
@mrperfect6700 Жыл бұрын
Bhai same here yarr...
@samirbante8554
@samirbante8554 Жыл бұрын
Bhai c to sikh le pehle
@Archit_Mehra
@Archit_Mehra 25 күн бұрын
let first = Math.random(); let ask = prompt("Game is guss a number"); let number = 0; do { if(first < ask) { ask = prompt("The actaul value is less Again enter the nuber"); } if(first>ask) { ask = prompt("The actaul value is Greater Again enter the nuber"); } number = number + 1; }while(first != ask); if(first == ask) { console.log("you have guessed write value"+first+"You score is "+(100-number)); } //My first program in js Thank you so much for harry Sir
@NitinRana-l3s
@NitinRana-l3s 2 күн бұрын
let first = Math.random()*100; first=Number.parseInt(first); let ask = prompt("Game is guss a number"); ask=Number.parseInt(ask); let number = 0; do { if(first < ask) { ask = prompt("The actaul value is less Again enter the nuber"); } if(first>ask) { ask = prompt("The actaul value is Greater Again enter the nuber"); } number = number + 1; }while(first != ask); if(first == ask) { console.log("you have guessed write value"+first+"You score is "+(100-number)); } you have done right but it need some adjustment this is the right code code
@KrishnaAbhale-cn9qy
@KrishnaAbhale-cn9qy 7 ай бұрын
Because of your quick quiz I have learned a lot. Thank you bhai. I will give you prize after getting job
@anonyone8834
@anonyone8834 Жыл бұрын
3:37 after this I paused the video and wrote this code, btw idc if i am late and I can't win but instead I got a question, a challenge, that motivated me alot when I had written this code under 5 minutes. IDK if its good/bad but as a beginner programmer, I like my time let num = Math.floor(Math.random() * 100) let usrinput = prompt("Guess the Number:") let guesses=0 usrinput = parseInt(usrinput) while (num != usrinput) { console.log("Wrong number") if (num > usrinput) { console.log("The correct number is Greater") } else { console.log("The correct number is smaller") } usrinput = prompt("Guess the Number:") usrinput = parseInt(usrinput) guesses++ } console.log("YOU GUESS THE RIGHT NUMBER, YOU ARE SOOOO PRO YOUR SCORE IS:", 100-guesses)
@rohandabgar6626
@rohandabgar6626 2 жыл бұрын
You are such a great teacher. i never see teacher like yours. Thank u harry sir 🙏
@tirthsorthiya6320
@tirthsorthiya6320 2 жыл бұрын
This are the teachers we want. right?
@chetanazambare7674
@chetanazambare7674 Жыл бұрын
Thank so much for this course harry. your dedication to explaining each and every concept so easily is very appreciable.
@gayaprasad2291
@gayaprasad2291 2 жыл бұрын
Hello, Sir Solution of Sourabh Gautam: let x; let score = 0; let y = Math.floor(Math.random() * 100) do{ x = Number.parseInt(prompt()); if(x>y){ console.log(`${x} is greater than the Random Number`) } else if(x
@akshaynagarwal
@akshaynagarwal 2 жыл бұрын
Here y returns between 0-99 ,but the question have 1-100.
@tsa_vibes
@tsa_vibes 2 жыл бұрын
Where did the code check the number of chances given?
@umarjanbhat3819
@umarjanbhat3819 2 жыл бұрын
add 1 to y and you are good to go. 1 and 100 will be inclusive in this formula.
@gloryjaw4327
@gloryjaw4327 2 жыл бұрын
I think you should post this in comment section of replit
@kiduboy45
@kiduboy45 2 жыл бұрын
Nice bro
@Suraj03.
@Suraj03. Жыл бұрын
thanks for the exercise ---> 😀 here is the code --> let chances = 1; //The random number let number; number = Math.random()*100; number = Math.round(number); //the while loop for tries let value; do{ value = prompt("Enter an number :- "); if(number > value){ console.log("the number is bigger"); }else if(number < value){ console.log("the number is smaller"); }else{ console.log("your luck is ongoing"); } chances+=1; }while(number!=value) console.log("The total score is :- " + `${100-chances}`) note :- to find the number it took me lot of tries ...
@SombitPramanik
@SombitPramanik 2 жыл бұрын
wow harry vai 😍 😍 I am currently following your full web development playlist (103 videos) and simultaneously follow this full java script playlist for batter learning. unfortunately i am not able to participate that challenge but in future i try my best with your support . thangs harry vai love from West Bengal 😍
@educationalxentertainmente9351
@educationalxentertainmente9351 2 жыл бұрын
Hah! West bengal
@educationalxentertainmente9351
@educationalxentertainmente9351 2 жыл бұрын
Me too!
@educationalxentertainmente9351
@educationalxentertainmente9351 2 жыл бұрын
Shall we learn and make projects together??
@SombitPramanik
@SombitPramanik 2 жыл бұрын
@@educationalxentertainmente9351 yes contact me on email
@educationalxentertainmente9351
@educationalxentertainmente9351 2 жыл бұрын
@@SombitPramanik how can I know Email
@lovelysharma9897
@lovelysharma9897 2 жыл бұрын
Please is ke bad react js ka bhi course bnao ,easy to learn .this ultimate js course is really ultimate
@dipalikutmure1523
@dipalikutmure1523 Жыл бұрын
Yes we need it
@the.sirari
@the.sirari Жыл бұрын
Here is my approach....( i did it, not for first time but tried it 3 to 4 times but also saw some comments for the solution. My approach was firstly wrong in the while loop which was giving me run-time infinite loop error and also i have not understood the que properly but after seeing some solution i tried myself. Also I am seeing my approach a little bit copied but it is what it is 🙂) let r_no = Math.floor((Math.random() * 100) +1) console.log(r_no) let g_no let luck = 1 while (g_no!=r_no) { g_no = Number.parseInt(prompt('let\'s guess the no')) if(g_no>100){ console.log('plz Enter no between 1 & 100') } else if(g_no>r_no){ console.log('Guessed no.is big compared to random') } else if(g_no
@STEVE-tl4vh
@STEVE-tl4vh 2 жыл бұрын
Heres the solution: let x = Math.random() * 100; Math.round(x) x = Number.parseInt(x) let inp = prompt("Guess the number from 1 - 100: ") let count = 0 do { if (x > inp) { console.log("You guessed lower") inp = prompt("guess again: ") count++ } else if (x < inp) { console.log("You guessed higher") inp = prompt("guess again: ") count++ } else { console.log("You guessed it right!") } } while (x != inp) if (x == inp) { console.log("You guessed it right!") } let score = 100 - count console.log("Your score is", score)
@vgk-lm8vl
@vgk-lm8vl Жыл бұрын
let randomNumber=Math.floor(Math.random()*101),obj=[] let score=100; let chances=0,convert; let ask=prompt("Enter hidden number") chances++; while(ask!=randomNumber){ ask=prompt("You Enter wrong enter again") chances++; ask=Number.parseInt(ask) if(ask>randomNumber){ alert("Please enter lower number!") obj.push(ask) } else if(ask
@poor_thang
@poor_thang Жыл бұрын
bro..wo Harry hai, kuch bhi kar sakta hai... sadak se utha ke star bana sakta hai, thank you so much bro, tumne ek mech engineer se logic build karwa liya randomNo) { console.log("Entered number is greater than random number."); } else if (userInput
@metaaffinity
@metaaffinity Жыл бұрын
you can create this with this way //generate random number var random = Math.floor(Math.random()*100); console.log(random) // input by prompt and total 10 chances let input; let chances = 0; let tries = 0; do { input = Number.parseInt(prompt("enter your guess")); if(randominput){ console.log("guessed number is greater than "+input); } chances+=1; tries+=1 } while(random != input){ console.log("Good! you have gussed the number in "+tries+" tries") console.log(`your have earned ${100-chances} points`); }
@0xvineet
@0xvineet Жыл бұрын
bro apka print just opposite ho rha ,,, suppose random number 45 hai ,, to 50 input dene pr show krega "guess number is less than 50 and vise versa for 30 as input
@CodingWorld202
@CodingWorld202 9 ай бұрын
Now this what we call a top notch quality content.
@zero8717
@zero8717 Жыл бұрын
For those who want the code let x = Math.floor((Math.random()*100)+1) let chances = 0; let input = 0 while(input != x){ input = Number.parseInt(prompt("Enter number between 0 to 100")) if(input > x){ console.log("The number is smaller than " +input) } else if(input < x){ console.log("The number is bigger than " +input) } chances++ } console.log("Congrats Champ") console.log("Your score is " +(100 - chances)+ " and number is " +x)
@MirUrfeey
@MirUrfeey 8 ай бұрын
Thnx
@CrazeGamerz786
@CrazeGamerz786 3 ай бұрын
Hello Harry Sir I am watching this video now I just created this code in vs code editor thanks var num = Math.ceil(Math.random() * 100); console.log(num); var gnum = prompt(" the guess number between 0 and 100" ) if (gnum == num) alert("the number matched Good Work and number is: " +gnum); else{ alert('Not matched , try again and number is ' +gnum); }
@Huihuihuihuihui..
@Huihuihuihuihui.. 5 ай бұрын
do { var a=prompt('enter a number') console.log('Entered wrong number..') var c=Math.floor(Math.random() * 10) + 1; // var b =Number.parseInt(a) } while (a!=c) console.log('you have entered a correct number')
@1StoneYt
@1StoneYt 9 күн бұрын
THIS COURSE IS BETTER THAN PAID COURSES LOVE YOU HARRY BROTHER ❤
@aashishmiglani5878
@aashishmiglani5878 2 жыл бұрын
let x = Math.random() * 100; x = Number.parseInt(x) console.log(x) let y let chance = 0 while (y != x) { y = prompt("Enter the number") y = Number.parseInt(y) if (y < 101) { if (x > y) { console.log("Number is greater :Keep guessing") } else if (x < y) { console.log("number is lesser : Keep Guessing") } else { console.log("Great Work You guessed Right") } } else { console.log("Enter a Vaild Number") } chance++ } let guessing = 100 - chance console.log("Your Score is ", guessing) Thanks For This Playlist
@bot_programmer9
@bot_programmer9 Жыл бұрын
let guess = Math.round(Math.random() * 100); // console.log(guess); let num; let chances=0; do { num = prompt("guess the number"); num = Number.parseInt(num); if (num > guess) { alert("number is high"); } else if (num < guess) { alert("number is low"); // console.log("you guessed correct number"); } chances++; } while (num != guess); let score=100-chances if(num=guess){ console.log("you guessed correct number and scores are"+" "+score); } Really happy to submit the code and your learning always motivates me to do something great.....
@chiragshrivastava1530
@chiragshrivastava1530 7 ай бұрын
what's the logic behind Math.round()?
@yadneshpathade4657
@yadneshpathade4657 2 ай бұрын
let a = (Math.random()*100+1) a = parseInt(a); let i = -1 do{ var b = prompt("Enter a number"); b= parseInt(b); i++ if(b==a){ console.log("congrats you guessed the correct number") console.log("your score is",100-i+"%") } else if(b>a){ console.log("your number is greater than the actual number") } else if(b
@DiyaMangla
@DiyaMangla Жыл бұрын
I would like to thank you Harry. Here is my first Javascript code:- console.log("Welcome to my guess the number game!"); let a = Math.floor(Math.random()*100); console.log(a); //make it a comment to make it more interesting let b; //compare two values let count = 0; do{ b = Number.parseInt(prompt("Guess the number generated by Computer")); if(ba) console.log("You entered a number which is greater than autogenerated number") count++ }while( b!=a) console.log("Huraah! You entered a correct number"); console.log("Total number of guesses:- " +count); //game ended
@MachineBuzz
@MachineBuzz Жыл бұрын
thank you harry bhai apke kimte vakt ke liye the code below is the answer of the following exercise let cn = Math.floor(Math.random()*100)+1; let n = prompt("Enter the expected Number btw 1 to 100") n = Number.parseInt(n) let i=0; while(n!= cn ){ {if(n0){ alert("Less than correct Number") n = prompt("Enter the expected Number btw 1 to 100") } else if(n>cn){ alert("Greater than correct Number") n = prompt("Enter the expected Number btw 1 to 100") } else if(n
@Anju-t3m
@Anju-t3m Жыл бұрын
let num = Math.floor(Math.random() * 100); console.log(num); let sum = 0; let i = 0; let a; do{ a = prompt("enter your no"); a = Number.parseInt(a); sum = sum+1; if(anum) { console.log("guess no is greater "); } else { console.log("guess no is matched "); } } while(a!=num) console.log(sum); console.log(100-sum);
@dark-bh9cy
@dark-bh9cy 2 жыл бұрын
let a; let gn; let sc = 0; a = Math.floor(Math.random() * 100); console.log while(a!=gn){ gn = prompt("guess the number: "); sc+=1; if(gn>a){ alert("guess numbered is greter then number") } else if(gn
@imranhashmi5828
@imranhashmi5828 Жыл бұрын
let a=Math.floor(Math.random() * 100); let i; let count=0; while(i!=a){ let p=prompt("enter a number you guess") i=Number.parseInt(p); if(i>a) { console.log("you enter a greater number"); } if(i
@ashblake894
@ashblake894 Жыл бұрын
For those who want the code here (Guess the number between 0 and 100): let random = Math.floor(Math.random() * 101); console.log(random) let chances = 0; let input; while (input != random){ input = Number.parseInt(prompt("Enter a Number between 0 to 100")); if(input != random){ console.log("Wrong! Try again.")} if (random>input){ console.log("The Number is bigger than " + input) } else if (random
@mohammadabbas1623
@mohammadabbas1623 Жыл бұрын
it's not the correct approach
@ashblake894
@ashblake894 Жыл бұрын
@@mohammadabbas1623 What is the right approach?
@sabinsapkota5953
@sabinsapkota5953 Жыл бұрын
you are good at this buddy.
@amit_vyas17
@amit_vyas17 Жыл бұрын
@@mohammadabbas1623 yes you are right there should be nested loops as we have to check the condition again and again although this code working fine but at some point it will create a bug and the correct code is ======= let number = Math.floor((Math.random() * 100) + 1); console.log(number) let chances=0; let input; while(input != number){ input = Number.parseInt(prompt("Guess the number between 0 to 100")) if(input!= number){ console.log("Try again!! You guessed it wrong") if(input > number){ console.log("Your guessed number is bigger than the random number") } else{ console.log("Your guessed number is smaller than the random number") } } chances++; } console.log("Woahh You guessed the right number") console.log("Your score is " + (100-chances) + " and the number is " + number)
@knandinij
@knandinij Жыл бұрын
In d last statement by mistake curly brace is used .program is correct
@azharuddinansari8867
@azharuddinansari8867 Жыл бұрын
thanks for giving such a interesting quizes, Harry Bhai!!!
@QuantumXdeveloper
@QuantumXdeveloper 2 жыл бұрын
I already did it using Java But very sad don't post it😂😂😂 Thank you harry Bhai ❤️❤️❤️
@diptiranjan18
@diptiranjan18 2 жыл бұрын
Yes Stone paper scissors waala question 😂
@lodhiyavishnu4714
@lodhiyavishnu4714 2 жыл бұрын
Yeah 😂
@viviesnotes
@viviesnotes 3 ай бұрын
const prompt = require('prompt-sync')(); const number = Math.floor((Math.random() * 100) + 1); let chances = 0; let guess; do { guess = prompt("Enter your guess: "); guess = Number.parseInt(guess); chances++; } while (guess != number) console.log("score:", 100 - chances); console.log("original number:", number);
@sarthaksinghal9269
@sarthaksinghal9269 2 жыл бұрын
You are the best teacher right now I am your fan kya samjhate ho bhai aap
@iqbalshaikh5874
@iqbalshaikh5874 Жыл бұрын
I didn't make till end but I made a program that generates random number and if entered wrong it prints "wrong number" with random number generated. I only google for math.floor(math.random). Other things i did by my self. I think this course provides value....
@HM-sid
@HM-sid 2 жыл бұрын
Thanks sir for valuable content!🙏
@IFTIKHARAHMED-h4i
@IFTIKHARAHMED-h4i 3 ай бұрын
function randomInteger() { return Math.floor(Math.random() * 100) + 1; } var i = 0; let result = randomInteger(); do{ var number = prompt("Guess rendom number.. ") if (numberresult){console.log("number is greater than rendom number try again ")} i = i + 1; }while(number != result) console.log("you win number in "+i+" attempts"); console.log("Yes you win the number " + result);
@dhruvkumar1065
@dhruvkumar1065 2 жыл бұрын
let number = Math.random() number = number*10 number = Math.floor(number)+1 let guess = 0 do { guess = prompt("Enter your guess between 1-10") guess = Number.parseInt(guess) console.log(guess == number?"MATCHED":"TRY AGAIN!!") } while(number != guess)
@BhaktaBhusanDas
@BhaktaBhusanDas 2 жыл бұрын
Harry bhai, maja aagaya.
@cartoonkd07
@cartoonkd07 9 ай бұрын
let num = Math.floor(Math.random() * 100) + 1; let chances = 0; for(let i=0; i num) console.log("To high"); } }
@adityameena7536
@adityameena7536 2 жыл бұрын
Sir Me apke web development ke course ko study ke rha hu. Aap ke course ki wjh se mujhe kabhi help Hui h HTML, CSS and JS ko sikhne me
@Elderny
@Elderny 2 жыл бұрын
const winnum = Math.floor(Math.random()*100) let chances = 2 const ask = () => { if(chances){ chances-- const number = prompt('enter what you think') if(number == winnum){ alert('you won');chances = 2 }else{ alert('try again');chances-=1 } } } ask()
@anuragsinghp2p
@anuragsinghp2p 7 ай бұрын
let random=(max,min)=>{ return Math.round(Math.random()*100+1) } let x=random(); console.log(x) let input; while (input!=x) { input=parseInt(prompt("enter the number :")) counter++ if(input>x){ console.log("the input is greater than the orignal number"); } else if(input
@gondsarthak1018
@gondsarthak1018 Жыл бұрын
harry bhai 30 mins lge lekin without cheating just reference k liye math.random dekha and baaki sb khud hi kiya thank you so much sir❤❤
@gentlyroasting4049
@gentlyroasting4049 2 жыл бұрын
HARRY WHERE SHOULD WE DISCUSS ANY FURTHER MORE QUESTIONS? IT WOULD BE GREAT if there is a group for us🙏.THANK YOU FOR TODAY'S CLASS!!🔥🔥 #HarryBhai
@Gaminator69
@Gaminator69 2 жыл бұрын
I am from Pakistan.I am learning C++ language by code with harry C++ Course.I love his teaching skill. He is a very good tutor. I love you bro. Love from Pakistan. May Allah blessed you.
@wasirj720
@wasirj720 2 жыл бұрын
Parhai pr focus kro or Pakistan ka name roshan kro
@Gaminator69
@Gaminator69 2 жыл бұрын
@@wasirj720 Thank you
@ahsinamawriab2811
@ahsinamawriab2811 2 жыл бұрын
Aese hi dono desh saath me chelenge toh acchi tarrakii karenge
@navinchainani4721
@navinchainani4721 2 жыл бұрын
How you understand hindi
@Saniyakhan0729
@Saniyakhan0729 2 жыл бұрын
Love you Harry bhai🤩
@VIPINKUMAR-hc9sz
@VIPINKUMAR-hc9sz Жыл бұрын
let c = Math.ceil(Math.random()*100) let i while (i !== c){ i = Number.parseInt(prompt("Enter correct No")) if (ic){ alert("Enter lower Num") } else { alert('You got it') } } console.log('You entered correct Number')
@sandeepsalaria2243
@sandeepsalaria2243 Жыл бұрын
// Returns a random integer from 0 to 100: const prompt = require("prompt-sync")({ sigint: true }); let number = Math.floor(Math.random() * 101); let cnt = parseInt(); cnt = 0; let input; let score = parseInt(); while (number != input) { input = parseInt(prompt("Guess the number:")); if (number > input) { console.log("Your Guess is less than Actual number ") } else if (number < input) { console.log("Your Guess is greater than Actual number ") } cnt++; } score = 100 - cnt; console.log("Your guess is right, number is:"+number); console.log("Your score is:" + score);
@Gaurav_Short
@Gaurav_Short 2 жыл бұрын
let point = 100; let lifes =5; let randN = Math.round(Math.random()*100) console.log('Hint: Number between(1 -100)'); do{ console.log('Your lifes: '+lifes) let userN = prompt('Enter Your Guess ?') if(userN==randN){ console.log('You Are Champion :D') console.log('Your Score: '+point) break } else if(userN>randN){ console.log('Your guess is high') point-=10; } else if (userN < randN){ console.log('Your guess is low') point -= 10; } lifes -= 1; }while(lifes>0) console.log('The Number is: '+randN)
@th_gauravthakur
@th_gauravthakur 2 жыл бұрын
❤️
@sarjeevanrajput7684
@sarjeevanrajput7684 2 жыл бұрын
Best 👍
@karenariash643
@karenariash643 2 жыл бұрын
💯
@Gaurav_Short
@Gaurav_Short 2 жыл бұрын
@@th_gauravthakur thnx
@Gaurav_Short
@Gaurav_Short 2 жыл бұрын
@@karenariash643 thx
@kamalsharma-pl9hu
@kamalsharma-pl9hu Жыл бұрын
let num = Math.random()*101 num = Number.parseInt(num) do { var x =prompt("enter a num"); x = Number.parseInt(x); if (x>num) { console.log("is greater") } else if(x
@SouthAsiaEntertainment
@SouthAsiaEntertainment 11 ай бұрын
let a=(Math.random()*51); a=Number.parseInt(a); console.log(a); let b=prompt("Enter Guessed Number(Hint Number is in between 1 to 50)"); b=Number.parseInt(b); if(b>a){ console.log("Enterd number is greater than number"); } else if(b
@amanamanyadav-gq1ti
@amanamanyadav-gq1ti 24 күн бұрын
hello harry bhaiya javascript 22 Exercise 1 - Guess the Number solve let ran=Math.floor(Math.random()*100); let count=0 for(let i=0;i
@RamanKumar-xu7cq
@RamanKumar-xu7cq 7 ай бұрын
const prompt = require("prompt-sync")(); let arr = 87; const arr1 = Array.from(String(arr), Number); let chances = 1; let a; do { if (a < arr) { console.log("Your number is less than the actual number"); chances++; } else if (a > arr) { console.log("Your number is greater than the actual number"); chances++; } a = prompt("Enter your number"); a = Number.parseInt(a); arr1.push(a); } while (a != 87); console.log("Your score is ", 101 - chances); console.log(arr);
@asifali-fc8xt
@asifali-fc8xt 2 жыл бұрын
Mr Harry hope aap javascript k is tutorial main Math.random or ye sari exercises sahi tarikey sy samjhein gy or is par khas focus karna hy aap ny koi point reh na jaey hope agey any waley lectures main aap random function ko briefly explain karein gy thanks, main is toturial ko regularly follow karta hn
@khudiramsoren
@khudiramsoren Жыл бұрын
HARRY Bhiya the way of your teaching style is indescribable and given below there are my code of exercise 1 , and HAPPY DUSSEHRA BHIYA. mujhe hurt ho raha hai big boss, big boss mujhe hurt ho raha hai😄😄😆 const prompt = require('prompt-sync')(); console.log("enter number between 1 to 100"); let number = Math.floor(Math.random()*100)+1; let num, score = 100, i = 0; do{ num = prompt("enter guess number : "); if(num == number){ console.log(num , " is correct number"); } else if(number < num){ console.log("the original number is between 1 t0 ",num); } else if(number > num){ console.log("the original number is between ", num , " to 100"); } i++; }while(num != number); if( i == 0){ console.log("your score is ", score); } else{ console.log("your score is ", (score-(i-1))); }
@SakshamGupta-p7g
@SakshamGupta-p7g 8 ай бұрын
let num = Math.floor(Math.random() * 100) + 1; let count = 0 do{ count++ let guess = prompt("Guess the number: ") if(guess == num){ break; }else if(guess
@SabaQureshi-d4h
@SabaQureshi-d4h 11 ай бұрын
let num = Math.floor(Math.random() * 100) + 1; console.log(num) let b = prompt("Enter the number"); b =Number.parseInt(b); if(num==b){ console.log("You entered the correct number ", +b+ "which is equal to "+num) }else if (numb){ console.log("The number " +num+ " is greater than the entered number ",+b) } Ghalti nikal dain .I'm new and learning javascript for the very first time from any youtube channel
@muma9353
@muma9353 Жыл бұрын
Your videos are just awesome ...
@Rahuldudi1349
@Rahuldudi1349 Жыл бұрын
i'm glad i did it without watching this video . let rn = Math.round(Math.random() * 99 + 1); guess = Number.parseInt(prompt("Guess the number")); while (guess != rn) { alert(`your number is ${guess < rn ? "smaller" : "bigger"}`); guess = Number.parseInt(prompt("Guess the number")); }; console.log(`You got it, the number is ${rn}`)
@mr_saam
@mr_saam Жыл бұрын
var number = Math.floor(Math.random() * 90) + 100; var guess = prompt("Silly game! Guess a number between 90 and 100"); guess = parseInt(guess); if (guess === number ){ alert("Congratulation! You Won"); } else { alert("You lost! The number was: " + number); } Try it 😎
@codewithrocky8934
@codewithrocky8934 2 жыл бұрын
Harry Bhai Love from Pakistan💌
@MyCodingCollege
@MyCodingCollege Жыл бұрын
const min = 10; const max = 20; let rand = Math.floor(Math.random()*(max-min+1)+min) let n, cnt=0; do{ n = prompt("Enter a Number (1 to 100): ") cnt++ if(n == rand){ console.log("Congratulations! You guessed it correct in just "+cnt+" times.") } else{ if(n
@shrabonisinha
@shrabonisinha Жыл бұрын
let number = Math.floor(Math.random() * 10); let chance = 0; let input; while(input!=number){ input = prompt("Enter your guess"); chance++; } console.log("The acctual number was",number,"Your score is : ",(100-chance))
@edward-soli
@edward-soli 11 ай бұрын
Buddy, This is a smart code but you forgot to tell the user about less than and greater than info...😅
@jaidevilliers9955
@jaidevilliers9955 Жыл бұрын
Here have the answer: const magicNo = Math.floor(Math.random() * 100) + 1; let inp; let ch = 0; do{ inp = Number.parseInt(prompt("Enter the no between 1 & 100")); if(inpmNo) console.log("The entered no is greater than magic no."); ch++; }while(inp!=magicNo); console.log("Congratulation you have predicted the magic no."); console.log("Your score is "+(100-ch)); ✌✌✌✌✌
@jatinnandwani6678
@jatinnandwani6678 2 жыл бұрын
Thank you bhai This course is helpful
@GOLUKUMAR-v1p8j
@GOLUKUMAR-v1p8j 26 күн бұрын
const original = parseInt(Math.random() * 100) + 1;// it will generate a number btw 1 and 100 let trial = 10; let guess = parseInt(prompt("enter your guess:")) while (trial) { if (guess === original) { console.log('wow guesse it right') } else { console.log("nahh... wrong guess") let guess = parseInt(prompt("guess agian :")) } trial -= 1; }
@priyanshusingh3405
@priyanshusingh3405 Жыл бұрын
let guess = Math.round(Math.random() * 10); console.log(guess); let input; let tries = 0; while (input != guess) { input = prompt("Enter Nummber== "); console.log('Wrong') tries += 1; } console.log("correct And You Win in = " + tries + " Tries");
@sagarkanchan29
@sagarkanchan29 3 ай бұрын
My code for the exercise -1 //1st line of code is used to fetch the prompt in VS code. Along with this npm init -y and npm install prompt-sync needs to be run. const prompt = require("prompt-sync")(); let randomNum = Math.floor(Math.random() * 100); console.log(randomNum); let guessNumber, guess = 0, score = 5; do { guessNumber = Number.parseInt(prompt("Guess the number: ")); guess++; if (guessNumber == randomNum) { console.log("Your guess was correct and your score is ", score); } else if (guessNumber > randomNum) { score--; console.log( "Your guess was higher than the original number and your score is: ", score ); } else { score--; console.log( "Your guess was lower than the original number and your score is: ", score ); } } while (guessNumber != randomNum && score != 0);
@bishalrout9948
@bishalrout9948 2 жыл бұрын
sry harry bhai i am useing the vs code because i am more comfortable in this so answer of the question i paste it here let num = Math.random() num=num*100; num=Math.round(num) console.log(num) // let num =50; let ans='' do { ans=prompt("gause a number between 0-100") ans=parseInt(ans); if (ans < num) { alert('you given number is less than the number') }else if (ans > num) { alert('your given number is greater then the number') } } while (ans != num); alert('congratulations you win')
@Shubham_Garg.4444
@Shubham_Garg.4444 Ай бұрын
function randomNumber(min, max) { return Math.floor(Math.random() * (max - min) + min); } let randomNum = randomNumber(1,100) ; let guessNum = prompt("guess the number: "); let cnt=0 ; while(guessNum != randomNum){ if(guessNum < randomNum) { console.log("your input is smaller than correct number") ; guessNum= prompt("enter greater number: ") ; cnt++ ; //break ; } else if(guessNum > randomNum) { console.log("your input is greater than correct number") ; guessNum= prompt("enter lesser number: "); cnt++ ; // break; } } console.log("you guess the correct number and it is", randomNum) ; let score = 100-cnt ; console.log("your score is= ",score);
@myself_ripon
@myself_ripon 2 жыл бұрын
Iss game me bohot mazza aya harry bhai😍😍
@usamabaig8591
@usamabaig8591 3 ай бұрын
Harry Sir Great
@heyitsritu
@heyitsritu 4 ай бұрын
const prompt = require("prompt-sync")() ; let ranNum = Math.floor((Math.random())*100); let chances = 5 do{ let num = prompt("Guess...??") if(ranNum == num){ console.log("you won"); break; }else{ console.log((num
@khanmujtaba1887
@khanmujtaba1887 Жыл бұрын
IK Raaz ki baat btaau harry bhai urf harry sir aap bhot famous ho india bhar me aur pate ki baat btaau aap ke channel pr itna Maal(content) hai ki shayad kisi primium website pr na ho
@MuhammadWaleedshahid-xp1yy
@MuhammadWaleedshahid-xp1yy 2 ай бұрын
let a = Math.floor(Math.random() * 100) let b = prompt("Enter a number") b = Number.parseInt(b) let c = 0 while (b != a) { if (b > a) { console.log("Your number is greater than the actual number") } else if (b < a) { console.log("Your number is less than the actual number") } b = prompt("Enter a number"); b = Number.parseInt(b); c++; } console.log("You have entered the correct number :" + b) console.log("Your score is " + (100 - c))
@gamezone7619
@gamezone7619 6 ай бұрын
let rnd=Math.random()*100+1 console.log(rnd) let input=prompt("enter a number to check you are close or not") input=Number.parseInt(input) if(rndinput) { console.log("your guess is less") console.log("actual number is ",rnd) } else if(rnd
@akjunior3617
@akjunior3617 Жыл бұрын
Thank you, Harry bhai
@flashnews5652
@flashnews5652 11 ай бұрын
let num=Math.random()*100; num=Math.round(num) let guess; let chance=10; do{ guess=prompt("enter your guess num :"); guess=Number.parseInt(guess); if(guessnum) { console.log("guess is greater") --chance; } else{ console.log("correct") } if(chance==0) { console.log("game over") } }while(guess!=num&&chance!=0)
@atharva_A
@atharva_A Жыл бұрын
let min = 1; let max = 5; let chances = 0; let randomnumber = Math.floor(Math.random() * (max - min + 1)) + min; const userinp = () => { return Number(prompt("Enter A Number:- ")); }; while (true) { let uinp = userinp(); chances++; if (uinp === randomnumber) { console.log("Congrats you have won!"); break; } else { console.log("Try Again!"); } } console.log("Number of chances it took you to guess the correct number is: " + chances); my attempt
@vsaurabh7879
@vsaurabh7879 2 жыл бұрын
If the user types negative numbers, show "enter a positive value". If the user types an even number, show the next 3 even numbers. If the user types an odd number, show the next 3 odd numbers.
@gloryjaw4327
@gloryjaw4327 2 жыл бұрын
let user_i = Number.parseInt(prompt("Enter your number")) if (user_i < 0){ console.log("Enter a positive value") } else if(isNaN(user_i)){ console.log("enter a number") } else if(user_i%2 == 0){ console.log(user_i+2,user_i+4,user_i+6) } else{ console.log(user_i+2,user_i+4,user_i+6) }
@vsaurabh7879
@vsaurabh7879 2 жыл бұрын
@@gloryjaw4327 are bhai aise to mera bhi ho gya tha..lkin loop lga k kasie krege
@gloryjaw4327
@gloryjaw4327 2 жыл бұрын
@@vsaurabh7879 You do not need to check if number is even or odd, adding 2,4,6 in it will always give its next even/odd value let inp = Number.parseint(prompt("Enter here") if (inp
@gloryjaw4327
@gloryjaw4327 2 жыл бұрын
@@vsaurabh7879 Like this: let inp = Number.parseInt(prompt("Enter your number")) function checker(input){ while(input>0){ for (let i = 0;i
@AdityaSingh-x2x
@AdityaSingh-x2x Жыл бұрын
let input; do { input = prompt("Enter any number"); input = Number.parseInt(input); if (input < 0) { console.log("Enter a positive number") } else if (input%2 == 0) { console.log("Next 3 even number are", input+2,",",input+4,"and",input+6) } else{ console.log("Next 3 Odd numbers are",input+2,",",input+4,"and",input+6) } } while (input < 0)
@ayoomxnu
@ayoomxnu 11 ай бұрын
let input = 0 let chance = 0 const guessed_number = Math.round(Math.random() * 100); while(input!=guessed_number){ input = Number.parseInt(prompt("Enter number between 0 to 100: ")) if (input>guessed_number){ console.log("Number is lower") } else if (input
@cryptoiin
@cryptoiin Жыл бұрын
let r = Math.floor(Math.random() * 101); let inp = prompt("Enter number to guess"); let score = 100; do { if (inp > 100) { score -= 1; alert("Enter number from 1 to 100"); inp = prompt("Enter number to guess"); } } while (inp > 100); while (inp != r) { score -= 1; alert("oo ooh wrong guess"); if (inp < r) { alert("Guess higher"); } else { alert("Guess less"); } inp = prompt("Enter Again to guess"); } alert("Hey You win " + "score = " + score);
@siddhikasharma9676
@siddhikasharma9676 Ай бұрын
let e ; let a = Math.random()*100 a=Number.parseInt(a) console.log("random_number:",a) e = prompt("Guess the number") e = Number.parseInt(e) if(e>a){ console.log("your number is greater") }else if(e
@royfamily9273
@royfamily9273 11 ай бұрын
Thanks Harry Bhaiya
@kamranasghar9577
@kamranasghar9577 Жыл бұрын
Its simple solution let guss = Math.floor(Math.random() * 100) let chance = 0; let tries; while(tries!=guss){ tries = prompt("Enter number to play game between 0 to 100") tries = Number.parseInt(tries) if(guss>tries) { alert("The number is greater then " + tries) } else if(guss
@pinkeshkumarjhakumarjha1587
@pinkeshkumarjhakumarjha1587 Жыл бұрын
let a = Math.floor(((Math.random()*100)+1)) let input = prompt('Guess the number') while(a !== input){ if(a == input){ break; } else if(input>a){ alert("You have guessed greater number") input = prompt('Guess the number') } else{ alert("You have guessed lower number") input = prompt('Guess the number') } } alert("Guessed Number is correct")
@rabean50
@rabean50 Жыл бұрын
its being lengthy!
@jammohsinali5272
@jammohsinali5272 Жыл бұрын
hello can you tell me how to done it
@vgk-lm8vl
@vgk-lm8vl Жыл бұрын
let randomNumber=Math.floor(Math.random()*101) let score=100; let chances=0,convert,tries=0; let ask=prompt("Enter hidden number") tries++; while(ask!=randomNumber){ ask=prompt("You Enter wrong enter again") chances++; ask=Number.parseInt(ask) if(ask>randomNumber){ alert("Please enter lower number!") } else if(ask
@vgk-lm8vl
@vgk-lm8vl Жыл бұрын
let randomNumber=Math.floor(Math.random()*101),obj=[] let score=100; let chances=0,convert; let ask=prompt("Enter hidden number") chances++; while(ask!=randomNumber){ ask=prompt("You Enter wrong enter again") chances++; ask=Number.parseInt(ask) if(ask>randomNumber){ alert("Please enter lower number!") obj.push(ask) } else if(ask
@kinggamer-xv3kx
@kinggamer-xv3kx 2 жыл бұрын
Thanks Harry bhai for the voucher but hum chahte hai ki aap hume roj aise hi homework dete rhe taaki hum or bhi aacha kr ske
@mr.joshi2002
@mr.joshi2002 Жыл бұрын
let x = Math.round(Math.random() * 10); let n; let count = 0; do { n = prompt("Guess the number between 1 to 10"); n = Number.parseInt(n); count++; } while (n != x); console.log("Congrats, you guess the number in " + count + " Attempt");
@mahnoorbaig8787
@mahnoorbaig8787 Жыл бұрын
let n=Math.floor(Math.random() * 10) console.log(n) for (let i=0;in){ console.log("Greater") } else { console.log("smaller") } }
@AkashKumar-fg5ej
@AkashKumar-fg5ej 2 ай бұрын
harry bhai m ne aise kiya... let x = Math.random()*100; x = Math.round(x); console.log(x); let runAgain=true; while(runAgain){ let u = prompt('soch k number bata'); u=Number.parseInt(u) console.log("tera number",u) if (x==u) { console.log("sabas beta tera same same hai") break } else{ console.log(x > u ? "tera number chota":"tera nuber bada hai"); } runAgain=confirm("tuje seconde chance chaiye bol ") };
@dcrecords1439
@dcrecords1439 Жыл бұрын
let min = 0; let max = 100; let score=0; let num =(Math.floor(Math.random() * (max - min + 1)) + min); let ask; do{ ask =prompt("put your number") ask=Number.parseInt(ask) if(ask>num) console.log("Number is smaller than " + ask) else if (ask
JavaScript in the Browser | JavaScript Tutorial in Hindi #23
10:14
CodeWithHarry
Рет қаралды 307 М.
Map, Filter & Reduce in JavaScript | JavaScript Tutorial in Hindi #20
12:49
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
黑的奸计得逞 #古风
00:24
Black and white double fury
Рет қаралды 25 МЛН
Who’s the Real Dad Doll Squid? Can You Guess in 60 Seconds? | Roblox 3D
00:34
Cool Parenting Gadget Against Mosquitos! 🦟👶 #gen
00:21
TheSoul Music Family
Рет қаралды 32 МЛН
DSA v/s Development | What to do for Placements?
9:15
Apna College
Рет қаралды 525 М.
Is AI & ML Worth the Hype?
11:14
CodeWithHarry
Рет қаралды 63 М.
Should You Learn Multiple Programming Languages? (The Truth)
8:29
CodeWithHarry
Рет қаралды 107 М.
JavaScript Script Tag | JavaScript Tutorial in Hindi #24
8:02
CodeWithHarry
Рет қаралды 264 М.
Number Guessing Game Using HTML CSS and JavaScript
33:11
OnlineITtuts Tutorials
Рет қаралды 3,2 М.
Best Data Analyst Learning Resources in 2024-25
10:17
CodeWithHarry
Рет қаралды 92 М.
Async/Await in JavaScript | JavaScript Tutorial in Hindi #59
20:08
CodeWithHarry
Рет қаралды 294 М.
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18