Generating a random number in javascript

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 90

  • @edugetters
    @edugetters 5 лет назад +10

    You are so great teacher. Your work is highly appreciable.

  • @swallowedinthesea11
    @swallowedinthesea11 4 года назад +1

    Thank you for the tutorial! Coming from Python, the start/end looks complex VS:
    import random
    dice = random.randrange(20, 26)

  • @madhusudankowlgi1113
    @madhusudankowlgi1113 6 лет назад

    Hitesh, your concept of viewing and doing is too good. Examples you have selected are excellent, easy to understand. Technically to the point. Hope to see more in further videos

  • @Technoholicplus
    @Technoholicplus 4 года назад

    let upper = 1;
    let lower = 10;
    if (upper > lower) {
    let randomizer = function(up, low) {
    let myRandom = Math.random() * (up - low);
    let final = myRandom + 20;
    return `the random value inclusive of ${upper} and ${lower} is ${Math.round(
    final
    )}`;
    };
    console.log(randomizer(upper, lower));
    } else if (upper === lower) {
    console.log("Upper Lower can't be same");
    } else {
    console.log("Upper value cannot be smaller than Lower");
    }
    Thanks, bro I used Math.round to include both upper limit and lower limit.

  • @ovirex
    @ovirex 5 лет назад

    Thanks man, I was looking for this because I didn't understand how it works but you explain it very well and simple. Greetings from Venezuela.

  • @abhishek_dam
    @abhishek_dam 3 года назад

    that was quite a good explanation man thank you I have been looking so much but couldn't find any except yours. thanks again

  • @pavantejavydhik7354
    @pavantejavydhik7354 6 лет назад +1

    such an interesting video, looking for it quite long time . lotsOfLove keep rocking Hitesh , 'm on my mac cant put smiles here please take all my wishes

  • @manojkumarm8398
    @manojkumarm8398 4 года назад

    Never Seen a Teacher like u✔

  • @vinaymanikant9710
    @vinaymanikant9710 6 лет назад

    Loving this series alot
    Hoping to have a complete bunch of JS series
    And sir please give alot of projects along with them

  • @Bajrang.707
    @Bajrang.707 5 лет назад +2

    This is really cool one!
    And you''re the great mentor for us!

  • @vinitrai5020
    @vinitrai5020 6 лет назад +2

    Hi Hitesh, great to follow your videos.I am learning a lot from these videos.Thanks a lot!!
    Here I have written a very simple game.I want to share the code
    let userTurn=function(){
    let user = Number(prompt('enter a random number'));
    return user;
    }
    let computerTurn=function(){
    let system = Math.floor(Math.random()*10);
    return system;
    }
    for(i=1;ib){
    console.log('user wins');
    }
    else{
    console.log('computer wins');
    }
    }
    What do you say about the code and how can I make it better.
    Thanks in advance.

  • @shankumondal2881
    @shankumondal2881 4 года назад

    You are not a programmer , you are a magician

  • @akshbansal7715
    @akshbansal7715 5 лет назад +1

    ceil and floor are actually other names for Lowest Integer Function and Greatest Integer Function

  • @snowfall1984
    @snowfall1984 2 года назад

    Thank you.. Now I understand the formula..

  • @unyieldingjarnail
    @unyieldingjarnail 5 лет назад

    Always nice stuffs from you. And I want to know if you can share your system configuration pls

  • @hometv4061
    @hometv4061 3 года назад

    it was 1:30 in the morning and you were making videos for us

  • @hackx_hive8221
    @hackx_hive8221 6 лет назад +3

    Your dedication really inspires..!👌👍🏼

  • @RainOnline
    @RainOnline 5 лет назад +2

    i can;'t wrap my head around the fact that i would have never been able to write this function from the top of my head

    • @RainOnline
      @RainOnline 5 лет назад +1

      yeah well, im back! and this looks way too easy. Ive used the math.random function in more complicated functions such as color and string generators. Don't give up!

  • @StarDoesntUpload
    @StarDoesntUpload 5 лет назад

    22/7 is not Pi, it’s just close to Pi. Pi is an infinitely long string of numbers, and is therefore impossible to write as a fraction.

  • @anil0407
    @anil0407 6 лет назад

    let message = "I love the tutorial";
    if(message)
    {
    console.log(message);
    }
    thank you sir. I am enjoying your tutorial.

    • @HiteshCodeLab
      @HiteshCodeLab  6 лет назад

      Thanks

    • @dikshitkaushik8387
      @dikshitkaushik8387 6 лет назад

      bhai there is no need if if else statement and u not use properly that if else statement stuff

    • @sanudajayathilaka3173
      @sanudajayathilaka3173 5 лет назад

      @@dikshitkaushik8387 nothing wrong with the code bro. He has checked whether the message is exist? if its true return message. He has done a wonderful job

  • @YoYo-eg6rc
    @YoYo-eg6rc 5 лет назад +1

    Thanks you sir , I clearly understand How it work

  • @stealthbusiness
    @stealthbusiness 4 года назад

    Thanks for putting the tutorial together. :)
    Is there a way to Password Protect online videos (RUclips, Vimeo... etc) with some if not all of these features?
    Random Password
    Set the Expiration time or date
    Set the Total time a video can be viewed
    Set how many times the password is allowed
    Setup Password Groups
    I know it's asking a lot, if you're busy, I understand. You seem to have the skills to make it happen. Just putting it out there.

  • @selimatasever4112
    @selimatasever4112 5 лет назад

    Thanks bro.. i liked the way you explain the details. Subscribed!!

  • @gbktechnologies6637
    @gbktechnologies6637 3 года назад

    23 video u ask subscribe , just now i did that. awesome videos .....life time videos

  • @mdmoinmoin8888
    @mdmoinmoin8888 6 лет назад

    love your teaching keep uploading videous like even if u dont get many views later on but many really watch all of it

  • @srikantdas2523
    @srikantdas2523 6 лет назад

    It's really an awesome tutorials for beginners. I am going to subscribe it.

  • @monikanb6120
    @monikanb6120 4 года назад

    Wow I really enjoii this series

  • @avisheksinha4264
    @avisheksinha4264 6 лет назад +3

    Thanks sir for this video 😊

  • @jaydattr9765
    @jaydattr9765 2 года назад

    let floatRes = Result
    can also bring the same output, no neet to write to.Fixed(2) for twice. at 5:12

  • @harjapx
    @harjapx 5 лет назад

    Instead of Math.Floor, if we provide '0' value to the toFixed it still shows integer value without any decimal places then what's the point of using the Math.floor?
    Please explain...

  • @nithsua
    @nithsua 5 лет назад

    And this series is really awesome

  • @nishantghosh3513
    @nishantghosh3513 4 года назад

    we should use round() for get its​ closest integer so why we use floor or ceil

  • @manuchowdary7848
    @manuchowdary7848 4 года назад

    Finally my confusion was clear

  • @ShubhamSharma-rm9ry
    @ShubhamSharma-rm9ry 6 лет назад

    sir, i like this video as compare to random password generator project.

  • @jackfrost8969
    @jackfrost8969 5 лет назад

    this is beyond perfect.
    thanks a ton.

  • @joshiadvait8
    @joshiadvait8 6 лет назад

    *Just because you started this series your subscribers got increased a lot
    I think You should put some more free series on react native & database connectivity with same as well it will increase subscribers in Huge nos*

    • @HiteshCodeLab
      @HiteshCodeLab  6 лет назад +5

      Check again. Views on regular videos is high and views on JS series is so low. Anyways, these numbers are just numbers. I am just looking to move forward.

  • @mohdsadique551
    @mohdsadique551 4 года назад

    I dont know why did you take this long route, i think you could have simply showed us :
    let dice = Math.floor(Math.random()*6)+1
    and its done.

    • @shreejasoni5171
      @shreejasoni5171 4 года назад

      maybe he is trying to teach upper and lower concept.
      btw I got output by using Math.floor(Math.random()*6)+1 thanku

  • @aWiseCoder
    @aWiseCoder 6 лет назад

    Thanks I understand The concept now

  • @2002utube
    @2002utube 5 лет назад

    I think you are a developer...may be you know which are the mostly used all functions in Math lib . May be this will be useful. Because there are many in the documentation.

  • @shawnedits161
    @shawnedits161 4 года назад

    sir how we can genreate random number in a given range without using math.Random() in javascript

  • @aurangzaibmanzoor1136
    @aurangzaibmanzoor1136 3 года назад

    how to stop generating the same random numbers with the database I want to generate roll numbers which should not be same so tell me.

  • @sonudeep6472
    @sonudeep6472 4 года назад

    But sir I have also got 0 .... sir what is the reason... please reply

  • @sulbhasharma92
    @sulbhasharma92 6 лет назад

    please also give series lyk this for node n react js too

    • @HiteshCodeLab
      @HiteshCodeLab  6 лет назад

      Available here
      courses.learncodeonline.in

  • @niharranjanbhuyan9839
    @niharranjanbhuyan9839 6 лет назад +1

    Result = 22/7
    But u have forgot to put let or var before result...
    But you got correct answer..How}??

    • @michaelobeng7660
      @michaelobeng7660 5 лет назад

      in javascript if you do not declare var or let the variable is still accessible and it becomes a global variable

    • @YoYo-eg6rc
      @YoYo-eg6rc 5 лет назад

      @@michaelobeng7660 yes you are true

    • @shreejasoni5171
      @shreejasoni5171 4 года назад

      watch his viedoe of var and let he is telling local and global

  • @EVOLUTIONSHORTSs
    @EVOLUTIONSHORTSs 4 года назад

    Can u create website for me i want to hire u as developer?

  • @chandanbaruah7692
    @chandanbaruah7692 6 лет назад

    concept clear thanks

  • @ruhankhandaker5198
    @ruhankhandaker5198 6 лет назад

    wao,, Another great video.

  • @HarpreetKaur-pm3so
    @HarpreetKaur-pm3so 6 лет назад +1

    "THE" best :)

  • @KK-wd5nc
    @KK-wd5nc 6 лет назад

    sir , wud u please tell us tht how to make dynamic img slider using JS ??????

  • @manuchowdary7848
    @manuchowdary7848 4 года назад

    Thanku

  • @samosrecaipozitiva1764
    @samosrecaipozitiva1764 4 года назад

    Thank you you are great !

  • @chetask4558
    @chetask4558 5 лет назад

    math.random() * 5+1 doesn't gave 0 value how to deal with that

  • @ShubhamGupta-qb4gu
    @ShubhamGupta-qb4gu 4 года назад

    Smallest Code
    let a = Math.ceil(Math.random()*6);
    console.log(a);

  • @babaji0997
    @babaji0997 6 лет назад

    Thank you so much sir......

  • @yeswanthchintapalli7144
    @yeswanthchintapalli7144 6 лет назад

    I NEED PANCARD VALIDATION THROUGH THE TEXTBOX THAT 5TH CHARACTER IN PANCARD NUMBER MUST MATCHES WITH THE SURNAME

  • @abazur7742
    @abazur7742 5 лет назад

    9:52 starts talking about random

  • @RakeshSharma-df2ie
    @RakeshSharma-df2ie 6 лет назад

    Hello sir can you please explain me this code
    //generate random numbers between 83 to 93
    let upper = 93;
    let lower = 83;
    let randomNum = Math.ceil(Math.random() *(upper - lower)) + lower;
    console.log(randomNum);

    • @RainOnline
      @RainOnline 5 лет назад

      93 - 83 = 10 . so you random a number from 0 to 10. and the end "+lower" means 83. , which means you random a number from 83 to 83 +10 which is 93, and result is 83 to 93

    • @hardik.motwani
      @hardik.motwani 5 лет назад

      You have used ceil so range will be from 1 to 10, + lower will make the range 84 to 93

  • @subhranil764
    @subhranil764 6 лет назад

    Nice sir:)

  • @thangathirupathi7257
    @thangathirupathi7257 4 года назад

    thank you

  • @abdullahalrifat4997
    @abdullahalrifat4997 3 года назад

    Thanks

  • @Srestha2023
    @Srestha2023 4 года назад

    why can't we just use math.ceil on math.random()*6

    • @shreejasoni5171
      @shreejasoni5171 4 года назад

      can you please elabore by which i can try

  • @yoyoma7273_6
    @yoyoma7273_6 5 лет назад

    Why don't we need to import math first?

  • @VIKASGUPTA-ec1kd
    @VIKASGUPTA-ec1kd 4 года назад +1

    who is here in 2020-corona panademic ?

  • @ANOOPKUMAR-cu2eo
    @ANOOPKUMAR-cu2eo 6 лет назад

    thanks sir

  • @Ashish-es4nk
    @Ashish-es4nk 6 лет назад

    Thanks Hitesh for being awesome. I just created a function for random and let me know what you think?
    jsbin.com/comuruh/edit?js,console

  • @edugetters
    @edugetters 5 лет назад +1

  • @_ghost_69.
    @_ghost_69. 4 года назад

    Well random in python is easy than js

  • @ovirex
    @ovirex 5 лет назад

    Figura del partido

  • @prabu2778
    @prabu2778 5 лет назад

    I think you are working in google

  • @danyrupesarputharaj6969
    @danyrupesarputharaj6969 6 лет назад

    yes sir

  • @jibinbaby5030
    @jibinbaby5030 4 года назад

    That was not tricky at all sir. Catched in the very first exercise.

  • @konstantinpavlovic8472
    @konstantinpavlovic8472 6 лет назад

    2:35 :DDDDDD

  • @nithsua
    @nithsua 5 лет назад

    do you love maths? cuz i hate it

  • @dsaha7473
    @dsaha7473 6 лет назад

    😂😂

  • @dahabodarman6012
    @dahabodarman6012 5 лет назад

    thank you