Number and Maths in Javascript | chai aur

Sdílet
Vložit
  • čas přidán 24. 02. 2023
  • Visit chaicode.com for all related materials, community help, source code etc.
    github.com/hiteshchoudhary/js...
  • Věda a technologie

Komentáře • 254

  • @pankajpanday6351
    @pankajpanday6351 Před 10 měsíci +59

    A simple explanation that I always think about is "Math.random() sirf 0 se 1 tk random number generate krta hai 0 is inclusive, 1 is exclusive....So in this statement Math.random() * 10, the result can never be equal to 10 qki 10 lane k lie usko 1 se mulitply hona pdega jo ki possible nahi hai, to result hmesha 10 se niche hoga (it could be 9.999999) but 10 nhi hoga, or iske upr se agar aap Math.floor(Math.random() * 10) krte ho to result 0 se 9 tk koi bhi integer ho skta hai but 10 nahi, to 10 ko bhi range me include krne k lie hum usme 1 add kr dete hai.....that is if you do Math.floor(Math.random() * 11) to result [0,10] tk aaega both inclusive.....and at last isme bas aap 1 add kr doge to result [1,10] m convert ho jaega....
    similarly, is concept ko max min m bhi leke jaa skte hai

    • @honblegaurav9917
      @honblegaurav9917 Před měsícem

      vahi to aur isne to dhang se samjhaya hi nhi aur fake smile karta rehta bus

  • @monty6393
    @monty6393 Před 9 měsíci +35

    22:29 actually here , the plus one is added to include the maximum number(20) into the range .. Zero case is already handled by adding +min after it ... For example let's say the random returns 0.99999 then multiply it with 11(20-10+1).. , we will get 10.989.... take the floor value of this which will be 10 and now add it with min value which is 10 so overall answer would be 20(the ending range). That's the maximum case..
    Similarly if random returns 0.0122... then everything will get 0 in the left and then adding min(10) to 0 will give us 10 which is the starting range..

  • @tech_channel110
    @tech_channel110 Před 11 měsíci +12

    best man
    best channel
    best language
    best way of explanation on internet
    you are legend in explanation world

  • @faridullah3841
    @faridullah3841 Před 10 měsíci +15

    Thank you for illuminating our learning journey, one JavaScript tutorial at a time. You're not just a teacher; you're an inspiration

  • @kanhucharanpradhan6066
    @kanhucharanpradhan6066 Před 11 měsíci

    i have already watched ur old javascript series bt this one is awesome

  • @shashankkumarpandey4184
    @shashankkumarpandey4184 Před 6 měsíci +1

    Amazing video, Thank you sir

  • @RahulSharma-wz6yv
    @RahulSharma-wz6yv Před 5 měsíci +3

    When we participate in the growth of others, we often end up growing ourselves first. You have done a lot for coders and continue to do so, which is great. I am eager to watch the complete Python course that is currently ongoing. However, I am very busy working on my clients' projects. In my remaining time, I am learning more about JavaScript to improve my knowledge. Although I already know JavaScript, learning from you is both fun and fortunate for me.
    Thanks for all you are doing !

  • @user-gy3bf1pe9y
    @user-gy3bf1pe9y Před 9 měsíci

    you are truly a indian inspiration mentor . thank you for serving india and across the world through your talent

  • @thetech17
    @thetech17 Před 9 měsíci +1

    Awesome Sir Thank you👍

  • @suryanshjain4739
    @suryanshjain4739 Před rokem

    Amidst these tough days of my life ,your videos are keeping me calm and sane....your voice is really soothing and the way you explain is impeccable

  • @kushagraagrawal7690
    @kushagraagrawal7690 Před 4 měsíci +3

    Formula for generating random number : Math.floor(Math.random() * (total no. in the range)) + min_number
    For example : if you want to generate random number between 0 to 10, then min no. is 0, max no. is 10, total no. in the range is 11 ( max - min + 1), now putting to formula :
    Math.floor(Math.random() * (11)) + 0

  • @shakib1010
    @shakib1010 Před 11 měsíci

    I find this tutorials are so relaxing. 😀 Great playlist.

  • @tech_channel110
    @tech_channel110 Před 11 měsíci +3

    sir your ability to convey intricate JavaScript concepts in a way that's both approachable and engaging is truly commendable, making us true asset to the learning community."

  • @Raj10185
    @Raj10185 Před 10 měsíci

    Nice explanation of Math.random . i really like it

  • @yosayaan7013
    @yosayaan7013 Před 2 měsíci +1

    You are the best Teacher i have ever had

  • @jrahul42
    @jrahul42 Před 12 dny

    Nice video concept clear about numbers and math thanks

  • @malaikaishfaq2717
    @malaikaishfaq2717 Před 11 měsíci

    literally you're savour i singed up for ibm Frontend development on crousera although that's expensive and paid course but cloud not understand anything and came back to this series

  • @rishineupane
    @rishineupane Před 4 měsíci

    Thank You for explaining very clearly and precisely

  • @babarshabbir2554
    @babarshabbir2554 Před 2 měsíci

    "Excellent overview of number & math concepts in JavaScript! Clear explanations and examples. #js"

  • @user-mo1sy5ck7r
    @user-mo1sy5ck7r Před 4 měsíci

    best Series ALL OVER UNIVERSE, thank you Sir 🙏

  • @Arindam_1729
    @Arindam_1729 Před rokem

    Thanks sir! Keep providing such videos!!
    This is Pure Gem!

  • @yogeshkumarpatil591
    @yogeshkumarpatil591 Před 7 měsíci

    Thank you for making such a beautiful javascript tutorial. Because You teach the actual javascript which is necessary for actual production development need. Very Very thank you. I will share your channel as much as possible to everyone. I really like your teaching style and I aslo need that type of javascript teacher. God bless you.

  • @sahilbutala6911
    @sahilbutala6911 Před 8 měsíci

    The way are you teaching ❤️✨✨,i never seen ever my life... Thanks for this series sir

  • @abhinavgupta4866
    @abhinavgupta4866 Před rokem

    The best thing I'm seeing in whole week.

  • @user-lo3hv9wb9u
    @user-lo3hv9wb9u Před 5 měsíci +5

    ----- SUMMARY -----
    Video 12 - Number and Maths in Javascript
    const score = 400 // JS auto detects it as a number
    const balance = new Number(100) // Using Number Function to explicitly define number in JS
    console.log(score) // 400
    console.log(balance) // [Number: 100]
    Note: Number has comparatively less prototype properties (methods) than String
    Methods with examples:
    1. balance.toString() // This converts a number into string
    2. balance.toString().length // Once we convert it to String, all properties / methods of Strings are now open to us, such as length
    3. balance.toFixed(2) // Used to reduce or round of to specific decimal values
    - Use Cases
    a. After calculation of GST
    b. In Ecommerce website
    4. const otherNumber = 23.8966
    otherNumber.toPrecision(3) // Output - 23.9
    otherNumber = 123.8966
    otherNumber.toPrecision(3) // Output - 124
    otherNumber = 1123.8966
    otherNumber.toPrecision(3) // Output - 1.12e+3 (exponential value)
    5. const hundreds = 1000000
    hundreds.toLocalString() // By default it converts into US standards
    hundreds.toLocalString('en-IN') // As per Indian Standards
    (Note: Check other formats in MDN Docs)
    6. Other methods
    .MAX_VALUE
    .MIN_VALUE
    .MAX_SAFE_INTEGER
    .MIN_SAFE_INTEGER
    ----- Maths in JS ----
    Maths library comes along with JS
    Methods ----
    1. Math.abs() // Converts +ve / -ve integer values to positive
    2. Math.round(4.3) // Output - 4
    3. Math.round(4.6) // Output - 5
    4. Math.ceil(4.2) // Output - 5 (gives top value)
    5. Math.floor(4.9) // Output - 4 (gives bottom value)
    6. Math.min(4,3,6,8) // Output - 3
    7. Math.max(4,3,6,8) // Output - 8
    8. Math.random() // Gives random value between 0 & 1 in decimals
    Math.random() tricks -----
    Math.random()*10
    Math.random()*10 + 1 // This assures that values are atleast 1 & more than 1
    (Math.random()*10) + 1 // To avoid any BODMAS rule miscalculation
    ---- Trick to randomize value between range ----
    const min = 10
    const max = 20
    const randomValue = Math.floor((Math.random() * (max - min + 1)) + min)

  • @boomaboom6458
    @boomaboom6458 Před 10 měsíci +1

    G sir my nay pichla assesment kiya string kay methods ka bahut kuch sikhnay ku mila thank you

  • @Instrumentation010
    @Instrumentation010 Před 8 měsíci

    As usual enjoying this extra ordinary explanation of topics..

  • @pranjalgogoigaming-1209
    @pranjalgogoigaming-1209 Před 8 měsíci

    Awesome video of Math object

  • @sounaksaha1455
    @sounaksaha1455 Před rokem

    Sir, aise hi aap pls roz video dala kijiye, phir padhne mein bhi maza aayega...... Thanks a lot for your top notch hindi tutorials

  • @workspaceronnie8283
    @workspaceronnie8283 Před 9 měsíci

    I just started this course so far It have helped me a lot looking forward to know more about js. Bhaiya one humble request to make a complete video on how to approach companies .

  • @tech_channel110
    @tech_channel110 Před 11 měsíci +1

    keep providing us such an amazing lectures
    May you live long life
    love from Pakistan

  • @webStream258
    @webStream258 Před 4 měsíci

    Great Man (Salute to you for providing such an amazing content for us ) Thanks
    Btw following you from Pakistan 😍😍😍

  • @akashthoriya
    @akashthoriya Před 11 měsíci +1

    Explanation is to the point 🔥
    toPrecision and Math.random() part was great

  • @HimanshuMeena-hi9nq
    @HimanshuMeena-hi9nq Před měsícem +1

    Formula for generating random number : Math.floor(Math.random() * (total no. in the range)) + min_number
    For example : if you want to generate random number between 1 to 6, then min no. is 1, max no. is 6, total no. in the range is 6 ( max - min + 1), now putting to formula :
    Math.floor(Math.random() * (6)) + 1
    this could be used for ludo dice

  • @barmoonz9769
    @barmoonz9769 Před 2 měsíci

    sir your javascript series just became a game changer of my programming experience❤

  • @ZiaUrRehman-pv8mw
    @ZiaUrRehman-pv8mw Před 7 měsíci

    OutStanding Explaination💖💖💖

  • @kazitanim007
    @kazitanim007 Před 7 měsíci

    Amazing teaching skill brother, keep up the good work. Also please make a video on how to get a job with basic HTML, CSS & JS while we keep learning.

  • @user-ud6qx2dv8y
    @user-ud6qx2dv8y Před měsícem

    thanks for sharing quality content

  • @beautyspot3929
    @beautyspot3929 Před 10 měsíci

    kia baat ha sir ap ke 😍

  • @PriyaSingh-ve9lf
    @PriyaSingh-ve9lf Před 5 měsíci

    u made javascript easy for me

  • @BioChemAcademy
    @BioChemAcademy Před 6 měsíci

    I was really having a bad day, but what make me calm and relax these days are watching your videos, thank you so much for everything sir you are an inspiration

  • @mrHock86
    @mrHock86 Před 2 měsíci

    continuining day 3. Amazinng content sir ji.

  • @muneebshabbir9696
    @muneebshabbir9696 Před 10 měsíci

    thank you your videos make easy js for me

  • @surajrao123
    @surajrao123 Před 9 měsíci

    sir aapki sari video bhot helpful hain, thank you. sir vo sach me chai tha kya😄😄

  • @RG_official.
    @RG_official. Před 9 měsíci

    Really like the playlist.

  • @zohaibalishah91
    @zohaibalishah91 Před 2 měsíci

    Sir You Are Just Awesome

  • @richa-singh09
    @richa-singh09 Před 2 měsíci

    well explained ...... thank you so much

  • @ankittiwari3421
    @ankittiwari3421 Před rokem +1

    sir ap ki padani ka alg style pura cosept clear ho jata h

  • @harshkesharwani5112
    @harshkesharwani5112 Před 11 měsíci +10

    At 22:26 if min =10 and max=20 then the value (Math.floor(Math.random()*(max-min +1)) ) => ensure that it will give value in the range [0,10] ..You have said 1 is added to avoid 0 but basically 1 is added to increase the range upto (10) ..if we will not add 1 it will give value in the range [0,9] .. Please clarify it ..And thanks for providing such valuable content.. Love You bhaiyya great series❤️!

    • @persevere08
      @persevere08 Před 11 měsíci +1

      you are absolutely right, basically one is added to set the uppper limit to max value.

    • @rajrajeshwarsingh3119
      @rajrajeshwarsingh3119 Před 10 měsíci +3

      Hey, bro in MDN docs it is clearly mentioned Math.random() returns that number that's greater than or equal to 0 and less than 1. So either you include 20 by adding 1 or exclude it by not adding 1, my suggestion is don't add 1, just go with the tradition i.e. docs.
      *And if you want to include 20 you have to add 1 inside(max- min + 1) not ((max-min) + 1), if you do this you'll get where we started where the value 10 will be excluded i.e. bodmass magic.
      *But in the video, there is a small explanation mistake at 20:08 where he @chaiaurcode says to avoid 0 you have to add 1 there i.e.(max- min + 1), if you do this only this step you'll get 0 value at some point there is a slimmest of chances because when Math.random() = 0, you will always get 0 because when you multiply anything with 0 obviously you'll get 0. So there's no point in adding "1" here because you'll get 0 at some point. Instead, he'd have added + 1 in the last equation.
      *Because when you look at the last equation it is correct in terms of the question where we want to include 10 and 20 as well. eg. (0.91*11) +10 = 20.01 or (0*11) +10 = 10😎😎. Hope that I've made my point. At last, JavaScript is a forgiving language so forgive it 😬😬and move on....
      You can refer to the same here developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random

    • @armorkinggaming1933
      @armorkinggaming1933 Před 10 měsíci

      @@rajrajeshwarsingh3119 The formula is correct. If you want to check, type the values:
      min1 = 10
      max1 = 20
      console.log(Math.floor(0.99999 * (max1-min1 + 1)) + min1);
      console.log(Math.floor(0.00000 * (max1-min1 + 1)) + min1);
      You can see, the formula is giving correct results for boundary cases and if boundary cases are correct, it means rest of the values will also be fine.

  • @abbykrm
    @abbykrm Před 11 měsíci

    Thanks Hitesh it's really helpful to revise the basics ❤❤

  • @vivektiwari6200
    @vivektiwari6200 Před rokem

    The things you are charity in free, can't be got in paid too. thanks a lot sir.

  • @babarshabbir2554
    @babarshabbir2554 Před 2 měsíci

    "Excellent tutorial! Clear explanations of number and math concepts in JavaScript using Chai. Highly recommended."

  • @ApexModi6000
    @ApexModi6000 Před 10 měsíci

    maine pehle padha hua tha JavaScript but ye sab nahi pata tha Thank You sir for this amazing course!!

  • @manthanharale3877
    @manthanharale3877 Před rokem

    the formula was very intresting and this class was very memorebel

  • @user-fh6jk9vy7w
    @user-fh6jk9vy7w Před 9 měsíci

    great effort

  • @WaqasKhanDurrani
    @WaqasKhanDurrani Před 12 dny

    Great explanation

  • @nikhatansari3310
    @nikhatansari3310 Před 9 měsíci +1

    Thank you so much sir 😊

  • @tahasiddiqui4968
    @tahasiddiqui4968 Před 4 měsíci

    You are great

  • @manojgyanwali2434
    @manojgyanwali2434 Před 3 měsíci

    Thank you for this series

  • @ByteNinjas69
    @ByteNinjas69 Před 10 měsíci

    excellent...

  • @Sarvesh_Coder
    @Sarvesh_Coder Před rokem

    Are garda hai ye wala video, har baar ki tarah ji😀

  • @manemanoj3068
    @manemanoj3068 Před rokem +1

    Excellent,useful content Bhai..

  • @aryangaur228
    @aryangaur228 Před 11 měsíci

    Thanks for this amazing tutorial sir!

  • @DostMuhammad-sd6rx
    @DostMuhammad-sd6rx Před 2 měsíci

    amazing keep it up

  • @thecalgarians4597
    @thecalgarians4597 Před 6 měsíci

    A granular detail that someone may miss while watching the video. Math.random() returns values 0 to 1 where 0 is inclusive but 1 is excluded.
    Overall, mind blowing series thus far. I'm binge watching :)

  • @user-rl3bq1um1f
    @user-rl3bq1um1f Před 8 měsíci

    Hi dear Hitesh Sir, I liked your way of teaching, because you are not taking long time to explain any topic. I watched and visit other youTube channel instructor who have 1M, 2M, 5M. but they all are taking so long time to give less knowledge and understanding to us. I don't want to publish these name but they are copying you in this paid cources, and session. it's my bad, I came here after mess around/ wasting my time and energy there. And literally your video quality and editing,animation, voice quality it's superb. I am requesting for DSA from you. please provide us. best DSA series. i will be wait for the same. and thank you for providing such a nice content in free of cost. you are great person and my ideal person also.

  • @ahmedbaig8543
    @ahmedbaig8543 Před 7 měsíci

    "🌟 Great content, Chai aur Code! Your videos are both informative and engaging. I've been learning a lot from your tutorials, and the way you explain complex concepts makes coding more accessible. Keep up the fantastic work! 👏💻 #LearningFromTheBest #ChaiaurCode"

  • @sagarbhavel8266
    @sagarbhavel8266 Před 7 měsíci

    this video is really helpfull.

  • @nityasahajisomani
    @nityasahajisomani Před 7 měsíci

    content level 😍👌

  • @krishnavamsi1126
    @krishnavamsi1126 Před 2 měsíci

    thanks bro learnt new things

  • @akroyalmaker
    @akroyalmaker Před 3 měsíci

    1 no. sir ji💯💯

  • @iamkmsyed
    @iamkmsyed Před 5 měsíci

    Thanks Sir

  • @softheartpeople
    @softheartpeople Před 9 měsíci

    awesome

  • @universalbeats.....8242
    @universalbeats.....8242 Před 3 měsíci

    Best series ❤

  • @ashishkumarranjan808
    @ashishkumarranjan808 Před 10 měsíci

    Great

  • @pubgwala5104
    @pubgwala5104 Před 10 měsíci

    Good one

  • @harshitatripathi2185
    @harshitatripathi2185 Před 2 hodinami +1

    console.log((Math.random()*(max-min))+min); it will also work.

  • @abhisheksingh_26
    @abhisheksingh_26 Před 5 měsíci

    Super❤

  • @manthanharale3877
    @manthanharale3877 Před rokem

    frist if all thankyou so much sir, and i think our jen-z are very lucky bicos of we have such kind of teachers.

  • @hiphop861
    @hiphop861 Před 8 měsíci +1

    Thank you
    ❣🥰🥰

  • @taashukumar1155
    @taashukumar1155 Před 9 měsíci

    maja aa gya chicha jaan

  • @AmanKumar-un1he
    @AmanKumar-un1he Před 6 měsíci

    We would really appreciate a series on DSA with JS.

  • @user-dy8hk5xj3r
    @user-dy8hk5xj3r Před 9 měsíci

    good sir

  • @user-bh6ic4bm3m
    @user-bh6ic4bm3m Před 5 měsíci

    Shukriya,

  • @_tobecontinued
    @_tobecontinued Před 3 měsíci

    Gazab :)

  • @Vikram_Singh_CS
    @Vikram_Singh_CS Před rokem

    Nice Explanation!!

  • @akashbhosale3634
    @akashbhosale3634 Před 2 měsíci

    gud one

  • @sayandipbhattacharya3097
    @sayandipbhattacharya3097 Před 4 měsíci

    Hum isse formula ko use karke ek simple otp generator bana skte jisse understanding or clear hogi
    Hum bas agr range ko jo min or max likthe hai usse agr hum me min = 100000 and max me max = 999999 krde to hume 6 digt OTP ka range mil jata hai. Principle ekdam same hai bas range ko increase kar do.
    Example:
    function Otp() {
    let min = 100000
    let max = 999999
    console.log(Math.floor(Math.random() * (max - min + 1) + min));
    }
    Otp();
    Try kar ke dekho or ache se samjh ajyga Math.random with range ka case.

  • @tarungehlaut4500
    @tarungehlaut4500 Před rokem

    amazing video sir!!

  • @jiteshtechbeast
    @jiteshtechbeast Před rokem +1

    This man is ❤❤❤

  • @himanshusain2597
    @himanshusain2597 Před 11 měsíci

    Quality content ❤

  • @anonymous_q_ho1245
    @anonymous_q_ho1245 Před 6 měsíci

    Thanks for this wonderful contain 😊 and the way u teach is really appropriate
    Last line code was little complex but that you you give a good example
    Although I think I can use Math.ceil isnted of Math.floor
    But I do understand why did u used this example 😊

  • @Dev-Phantom
    @Dev-Phantom Před 6 měsíci

    cool

  • @Bring_Up_Change
    @Bring_Up_Change Před 5 měsíci

    Hello sir...main sochra tha ki agar aap Javascript ke concepts padhaye with live implementation of each in the realtime projects. Sir, this will really help the students as they will be knowing what will be the purpose of each topic.

  • @manthanharale3877
    @manthanharale3877 Před rokem

    my every daut was clear and now iam good in numbers and math

  • @vikasagrawal9945
    @vikasagrawal9945 Před 10 měsíci

    I like video ❤❤❤❤❤❤

  • @ankushladani496
    @ankushladani496 Před rokem

    Dhanyawad guruji 🙏

  • @pratibhaverma2063
    @pratibhaverma2063 Před 6 měsíci

    At time 5:23 when the balance is converted to string using the to string() function , is it the copy of balance that is converted or the original variable?I'm asking in reference to the stack heap vedio previously watched of this playlist.

  • @livecodealone
    @livecodealone Před 2 měsíci

    Sir chai aur code is best

  • @suyashjain3223
    @suyashjain3223 Před 2 měsíci

    In case someone has doubt in generating the random number between min and max value. //Getting a random integer between two values
    console.log(Math.floor(Math.random() * (max-min)) + min)// The maximum is exclusive and the minimum is inclusive
    console.log(Math.floor(Math.random() * (max - min + 1)) + min)// The maximum is inclusive and the minimum is inclusive