Let num = Math.round((Math.random)*100); Console.log(num); Random number is done
@sobansaleem34927 ай бұрын
@@user-kq5up7fy2u what's the +1 for?
@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
@Shekhuguruji5 ай бұрын
there is a flaw, your code will generate a random number between 0 to 99, not 1 to 100
@kashif2niazi5 ай бұрын
@@Shekhuguruji let n=Math.floor(Math.random()*99)+1
@Shekhuguruji5 ай бұрын
@@kashif2niazi yep this is correct now
@nitubhuwalka9620 Жыл бұрын
I did the same program in python from your course by myself and now this time through javascript course...... Thank you harry
@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.
@learndigitalskills89322 жыл бұрын
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 Жыл бұрын
Sikh gaya kya javascript
@learndigitalskills8932 Жыл бұрын
@@samirbante8554 yes
@tirthsorthiya63202 жыл бұрын
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 Жыл бұрын
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")
@Richhera7 ай бұрын
Bhai tera comment try karke muje lagra hai abhi muje kuch nahi aya hai
@utkarshanikam287Ай бұрын
😅😅😂@@Richhera
@hrithik52202 жыл бұрын
Legend Harry Bhai🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 Aapka complete 1 video Wala hrml css course ne aag laga diya .thankyou so much
@pg_piyush2 жыл бұрын
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 Жыл бұрын
Bhai same here yarr...
@samirbante8554 Жыл бұрын
Bhai c to sikh le pehle
@Archit_Mehra25 күн бұрын
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-l3s2 күн бұрын
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-cn9qy7 ай бұрын
Because of your quick quiz I have learned a lot. Thank you bhai. I will give you prize after getting job
@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)
@rohandabgar66262 жыл бұрын
You are such a great teacher. i never see teacher like yours. Thank u harry sir 🙏
@tirthsorthiya63202 жыл бұрын
This are the teachers we want. right?
@chetanazambare7674 Жыл бұрын
Thank so much for this course harry. your dedication to explaining each and every concept so easily is very appreciable.
@gayaprasad22912 жыл бұрын
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
@akshaynagarwal2 жыл бұрын
Here y returns between 0-99 ,but the question have 1-100.
@tsa_vibes2 жыл бұрын
Where did the code check the number of chances given?
@umarjanbhat38192 жыл бұрын
add 1 to y and you are good to go. 1 and 100 will be inclusive in this formula.
@gloryjaw43272 жыл бұрын
I think you should post this in comment section of replit
@kiduboy452 жыл бұрын
Nice bro
@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 ...
@SombitPramanik2 жыл бұрын
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 😍
@educationalxentertainmente93512 жыл бұрын
Hah! West bengal
@educationalxentertainmente93512 жыл бұрын
Me too!
@educationalxentertainmente93512 жыл бұрын
Shall we learn and make projects together??
@SombitPramanik2 жыл бұрын
@@educationalxentertainmente9351 yes contact me on email
@educationalxentertainmente93512 жыл бұрын
@@SombitPramanik how can I know Email
@lovelysharma98972 жыл бұрын
Please is ke bad react js ka bhi course bnao ,easy to learn .this ultimate js course is really ultimate
@dipalikutmure1523 Жыл бұрын
Yes we need it
@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-tl4vh2 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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
@CodingWorld2029 ай бұрын
Now this what we call a top notch quality content.
@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)
@MirUrfeey8 ай бұрын
Thnx
@CrazeGamerz7863 ай бұрын
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..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')
@1StoneYt9 күн бұрын
THIS COURSE IS BETTER THAN PAID COURSES LOVE YOU HARRY BROTHER ❤
@aashishmiglani58782 жыл бұрын
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 Жыл бұрын
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.....
@chiragshrivastava15307 ай бұрын
what's the logic behind Math.round()?
@yadneshpathade46572 ай бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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-bh9cy2 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
it's not the correct approach
@ashblake894 Жыл бұрын
@@mohammadabbas1623 What is the right approach?
@sabinsapkota5953 Жыл бұрын
you are good at this buddy.
@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 Жыл бұрын
In d last statement by mistake curly brace is used .program is correct
@azharuddinansari8867 Жыл бұрын
thanks for giving such a interesting quizes, Harry Bhai!!!
@QuantumXdeveloper2 жыл бұрын
I already did it using Java But very sad don't post it😂😂😂 Thank you harry Bhai ❤️❤️❤️
@diptiranjan182 жыл бұрын
Yes Stone paper scissors waala question 😂
@lodhiyavishnu47142 жыл бұрын
Yeah 😂
@viviesnotes3 ай бұрын
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);
@sarthaksinghal92692 жыл бұрын
You are the best teacher right now I am your fan kya samjhate ho bhai aap
@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-sid2 жыл бұрын
Thanks sir for valuable content!🙏
@IFTIKHARAHMED-h4i3 ай бұрын
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);
@dhruvkumar10652 жыл бұрын
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)
@BhaktaBhusanDas2 жыл бұрын
Harry bhai, maja aagaya.
@cartoonkd079 ай бұрын
let num = Math.floor(Math.random() * 100) + 1; let chances = 0; for(let i=0; i num) console.log("To high"); } }
@adityameena75362 жыл бұрын
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
@Elderny2 жыл бұрын
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()
@anuragsinghp2p7 ай бұрын
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 Жыл бұрын
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❤❤
@gentlyroasting40492 жыл бұрын
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
@Gaminator692 жыл бұрын
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.
@wasirj7202 жыл бұрын
Parhai pr focus kro or Pakistan ka name roshan kro
@Gaminator692 жыл бұрын
@@wasirj720 Thank you
@ahsinamawriab28112 жыл бұрын
Aese hi dono desh saath me chelenge toh acchi tarrakii karenge
@navinchainani47212 жыл бұрын
How you understand hindi
@Saniyakhan07292 жыл бұрын
Love you Harry bhai🤩
@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 Жыл бұрын
// 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_Short2 жыл бұрын
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_gauravthakur2 жыл бұрын
❤️
@sarjeevanrajput76842 жыл бұрын
Best 👍
@karenariash6432 жыл бұрын
💯
@Gaurav_Short2 жыл бұрын
@@th_gauravthakur thnx
@Gaurav_Short2 жыл бұрын
@@karenariash643 thx
@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
@SouthAsiaEntertainment11 ай бұрын
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-gq1ti24 күн бұрын
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-xu7cq7 ай бұрын
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-fc8xt2 жыл бұрын
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 Жыл бұрын
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-p7g8 ай бұрын
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-d4h11 ай бұрын
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 Жыл бұрын
Your videos are just awesome ...
@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 Жыл бұрын
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 😎
@codewithrocky89342 жыл бұрын
Harry Bhai Love from Pakistan💌
@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 Жыл бұрын
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-soli11 ай бұрын
Buddy, This is a smart code but you forgot to tell the user about less than and greater than info...😅
@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)); ✌✌✌✌✌
@jatinnandwani66782 жыл бұрын
Thank you bhai This course is helpful
@GOLUKUMAR-v1p8j26 күн бұрын
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 Жыл бұрын
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");
@sagarkanchan293 ай бұрын
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);
@bishalrout99482 жыл бұрын
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Ай бұрын
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_ripon2 жыл бұрын
Iss game me bohot mazza aya harry bhai😍😍
@usamabaig85913 ай бұрын
Harry Sir Great
@heyitsritu4 ай бұрын
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 Жыл бұрын
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-xp1yy2 ай бұрын
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))
@gamezone76196 ай бұрын
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 Жыл бұрын
Thank you, Harry bhai
@flashnews565211 ай бұрын
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 Жыл бұрын
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
@vsaurabh78792 жыл бұрын
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.
@gloryjaw43272 жыл бұрын
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) }
@vsaurabh78792 жыл бұрын
@@gloryjaw4327 are bhai aise to mera bhi ho gya tha..lkin loop lga k kasie krege
@gloryjaw43272 жыл бұрын
@@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
@gloryjaw43272 жыл бұрын
@@vsaurabh7879 Like this: let inp = Number.parseInt(prompt("Enter your number")) function checker(input){ while(input>0){ for (let i = 0;i
@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)
@ayoomxnu11 ай бұрын
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 Жыл бұрын
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Ай бұрын
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
@royfamily927311 ай бұрын
Thanks Harry Bhaiya
@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 Жыл бұрын
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 Жыл бұрын
its being lengthy!
@jammohsinali5272 Жыл бұрын
hello can you tell me how to done it
@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 Жыл бұрын
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-xv3kx2 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
let n=Math.floor(Math.random() * 10) console.log(n) for (let i=0;in){ console.log("Greater") } else { console.log("smaller") } }
@AkashKumar-fg5ej2 ай бұрын
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 Жыл бұрын
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