#18 While vs For Loop | Which to use and When?

Поділитися
Вставка
  • Опубліковано 12 гру 2024

КОМЕНТАРІ • 140

  • @podcastwithom15
    @podcastwithom15 2 роки тому +15

    the answer is :
    let num = 123456;
    let num2="0";
    while(num>0)
    {
    let remainder=num%10;
    num2=num2*10+remainder;
    num=parseInt(num/10);

    }
    console.log(num2);

  • @sigmatronX
    @sigmatronX 2 роки тому +5

    Time stamp 1:14 //numbers 1 to 100 that are divisible by 3
    let count = 0; // to contain how many numbers are divisible by three
    for (let i = 1; i

  • @Prashuva
    @Prashuva Рік тому +6

    Assignment:
    let num = 123456;
    let num2 = 0;
    while(num>0)
    {
    let num1= num % 10;
    num2 = num2 *10 + num1;
    num = parseInt(num/10);
    }
    console.log(num2);

  • @clanhindustan358
    @clanhindustan358 3 роки тому +8

    Answer 6:25
    //Made by Anmol main
    let value = 564782
    let rev
    while (value) {
    rev = value % 10;
    value = parseInt(value / 10)
    console.log(rev);
    }

  • @jayantamondal3242
    @jayantamondal3242 Рік тому +6

    HW:
    let num = 564782, num2 = 0;
    while(num > 0)
    {
    num2 = (num2 * 10) + (num % 10);
    num = parseInt(num / 10);
    }
    console.log(num2);
    Once Again Thanks Navin sir

  • @manavyadav7505
    @manavyadav7505 3 роки тому +18

    //6:40 (assignment)
    let num = 1234;
    let num2= "0";
    while(num>0)
    {
    let remainder = num%10;
    num = parseInt(num/10);
    num2= String (num2 + remainder);

    }
    console.log(Number(num2)); // output is 4321

  • @shilpichadha7040
    @shilpichadha7040 2 роки тому

    >>6:16 Answer0)
    {
    value=num%10;
    temp=10*temp+value;
    num=parseInt(num/10);
    }
    console.log(temp);

  • @Vptheboss
    @Vptheboss 2 роки тому

    Answer at 6:18 time stamp
    let rev = 0;
    let num = 12345;
    rev = Number(String(num).split(' ').reverse( ).join(' '));
    console.log(rev);
    ouput is
    54321

  • @mphomanaka2263
    @mphomanaka2263 3 роки тому +4

    Thanks for clearance I’ve been asking myself even my friends when and where to apply a certain loop method on projects. Then today am the one who’s gonna help others on that one. Watching different tutorials with different developers helps me a lot because I learn 10 times more than at school.

  • @paschalokafor9043
    @paschalokafor9043 2 роки тому +3

    For outputing a range of numbers divisible by 3 you dont need that condition (i%3===0). You can simply increment the 'i' in your for loop by 3 and get same result. ie: -
    for(let i = 0; i < 100; i += 3){
    console.log(i)
    }

    • @sigmatronX
      @sigmatronX 2 роки тому

      i = 1

    • @Bob0126-k9j
      @Bob0126-k9j 9 місяців тому

      bro how can one get rid of the zero in the output

    • @paschalokafor9043
      @paschalokafor9043 9 місяців тому

      @@Bob0126-k9j use a condition eg if i > 0

  • @rithiknadar3312
    @rithiknadar3312 2 роки тому +5

    assignment:-
    let num = 28374983;
    let reverse = "";
    while (num > 0) {
    console.log(num % 10);
    reverse += num % 10;
    num = parseInt(num / 10);
    }
    convert = parseInt(reverse);
    console.log(convert, typeof convert);

  • @meerfulzele5569
    @meerfulzele5569 2 роки тому

    ANSWER FOR 1:14
    for(let i=1;i

  • @tgnsparvathi4774
    @tgnsparvathi4774 2 роки тому

    at 1:19
    for(let i = 1; i

  • @raghuvarandcruzjr
    @raghuvarandcruzjr Рік тому +1

    6:16 assignment
    let num = 564782, num2 = 0;
    while(num > 0)
    {
    console.log((num2 * 10) + (num % 10));
    num = parseInt(num / 10);
    }
    console.log(num2);
    output comes as expected vertically

  • @bd9389
    @bd9389 Рік тому +1

    Thanks Navin!!
    Here are Positive order loop i wrote.
    let x=56789
    let y=10000
    while(y>=1)//Positive order
    {
    z=parseInt(x/y)
    console.log(parseInt(z%10))
    y=y/10;
    }

  • @harsha4074
    @harsha4074 3 роки тому +2

    numbers divisible by 3 for(int i = 3;i

  • @mithunrathod6714
    @mithunrathod6714 Рік тому

    Time stamp 1:14
    for (let i=1; i

  • @utkarshgupta7371
    @utkarshgupta7371 3 роки тому +2

    Best teacher on youtbe, Kudos to navin sir

  • @thecreator9164
    @thecreator9164 10 місяців тому

    last question
    let num1=3927193
    num2=""
    while (0

  • @40kreshakshatriya9-i8
    @40kreshakshatriya9-i8 3 роки тому

    1:13
    I don't have my computer right now so I am just explaining it
    if i is % 3 and === 0 than console.log
    Peace out ✌️

  • @hvardhan55
    @hvardhan55 Рік тому

    Timeline:1:20
    for(let i=1;i

  • @mdsaqib2029
    @mdsaqib2029 3 роки тому

    We will use if statement in for loop and condition is if(i%3==o) then print the value of i

  • @sinoymk1770
    @sinoymk1770 2 роки тому +2

    let num = 398595
    let rev = ""
    while(num>0)
    {
    let rem=num%10
    rev=String(rev)+String(rem)
    num=parseInt(num/10)
    }
    console.log(rev);

  • @harsha4074
    @harsha4074 3 роки тому +2

    assignment
    small change inside ur code while loop
    num2 = num2*10;
    num2 += num1℅10;

  • @rajashekarbasa786
    @rajashekarbasa786 3 роки тому +2

    while(num > 0)
    {
    ld = num % 10;
    rev = rev*10 + ld;
    num = num / 10;
    }

  • @lexsaito1189
    @lexsaito1189 2 роки тому

    1:08
    let num;
    for(let i=1;i

  • @mehulbisht9708
    @mehulbisht9708 3 роки тому +13

    Sir this is a great playlist, but it's been 1 month and the video is still covering javascript basic syntax. Please proceed with the web part soon, really looking forward to it from you :)

    • @shoaib2307
      @shoaib2307 3 роки тому +1

      Noo, these basics are used everywhere

    • @manojkasam55
      @manojkasam55 3 роки тому

      Hello bro I am manoj from Hyderabad(Telengana) could please suggest me that how can I improve my communication skills like you.Could we have some talk

  • @Sayem-y4h
    @Sayem-y4h Рік тому

    1.19 // print the number divided by 3 between 1 to 100
    for (let i = 1; i

  • @jno1lilno
    @jno1lilno 2 роки тому

    let num = 56782;
    let num2=0;
    while(num>0)
    {
    console.log(num%10);
    num= parseInt(num/10);
    }
    console.log(num2)
    my answer for the homework at the end

  • @LetsRelaxABit
    @LetsRelaxABit Рік тому

    by learning JS from here, can we become more familiar with development using js? and this playlist covers all the advanced points which a programmer should known for development ?? kindly help anyone

  • @AmeerMuawia-i4p
    @AmeerMuawia-i4p 3 місяці тому

    let num = 321;
    let reverse = 0;
    while(num>0)
    {
    let remainder= num % 10;
    reverse = reverse *10 + remainder;
    num = parseInt(num/10);
    }
    console.log(reverse);

  • @micheledory644
    @micheledory644 Рік тому

    can we add && operator to for loop?

  • @alinapeng8602
    @alinapeng8602 3 місяці тому

    assignment:
    let num = 564782
    let num2 = 0
    let exponent = 5
    while(num>0)
    {
    num2 += (num%10) * 10**(exponent);
    num = parseInt(num/10);
    exponent--;
    }
    console.log(num2)

  • @kdeepika-h1j
    @kdeepika-h1j 10 місяців тому

    In String->
    let num=12345;
    let num2="";
    while(num>0){
    num2+=String(num%10);
    num=parseInt(num/10);
    }
    console.log(num2);

  • @theodorosgeorgitsis5600
    @theodorosgeorgitsis5600 Рік тому

    The mystey is solved...😂. Thx mate

  • @maharshbajpai
    @maharshbajpai 2 роки тому +2

    Thanks for this amazing series !!
    The answer for the assignment at 6:34 is
    let num = 4567;
    let rev = 0;
    while(num > 0) {
    rev = rev*10 + (num%10)
    num = parseInt(num /10)
    }
    console.log(rev) //7654

  • @TheTechCritic11
    @TheTechCritic11 3 роки тому +1

    my forloop never gets xecuted i need help

  • @40kreshakshatriya9-i4
    @40kreshakshatriya9-i4 3 роки тому

    You are going to make a video on Dom or not

  • @saivardhanreddy6698
    @saivardhanreddy6698 3 роки тому

    please tell about best books for javascript

  • @victorm3807
    @victorm3807 8 місяців тому

    // Reversing a number
    let num = 123456;
    let rev = 0;
    let rightDigit = 0;
    while (num > 0) {
    rightDigit = parseInt(num % 10);
    rev = rev * 10 + rightDigit;
    num = Math.floor(num / 10);
    }
    console.log(rev);

  • @sasi3774
    @sasi3774 3 роки тому

    Sir, please make videos on Artificial intelligence and machine learning

  • @thegreywalker
    @thegreywalker 3 роки тому +2

    Very nice series Sir ... Hope you will cover till advanced of JavaScript, One request sir ... please make a dedicated series on DevOps ... Website Deployment, Docker, Kubernetes, Jenkins, Especially Azure or AWS please sir ...

  • @saminenichandana5707
    @saminenichandana5707 3 роки тому +1

    Nice explanation

  • @vivangoyal108
    @vivangoyal108 3 роки тому

    for(i = 0; i

  • @kavyanj7082
    @kavyanj7082 3 роки тому

    Please make a video on java interview questions for freshers

  • @jessicarodrigues-dlouhy575
    @jessicarodrigues-dlouhy575 2 роки тому

    2:52 how did you come with divide 123456 by 10 to get 6?
    @telusko

    • @Ebenezer_Joshua
      @Ebenezer_Joshua Рік тому

      if we divide 123456 by 10, then the output is 12345.6. But in video percentage symbol (%) is used. The % symbol gives the remainder when 123456 is divided by 10. In this case, the output is 6.

  • @shivamnavthar5851
    @shivamnavthar5851 3 роки тому

    Very nice explaination.

  • @syamjir5588
    @syamjir5588 Рік тому

    /*digits of an integer --using java */
    import java.util.*;
    public class SampleClass {
    public static void main(String[]arg) {
    Scanner scr=new Scanner(System.in);
    System.out.println("enter the number");
    int n=scr.nextInt();
    digitinteger(n);
    }
    static void digitinteger(int n) {
    int arr[]=new int[100];
    int i=0;
    int r=0;
    while(n>0) {
    r=n%10;
    arr[i]=r;
    i++;
    n=n/10;
    }
    for(int j=i-1;j>=0;j--) {
    System.out.println(arr[j]);
    }
    }
    }

  • @alkagopi5957
    @alkagopi5957 Рік тому

    Reverse Output
    let reverseNum = 564782;
    let stringNum = reverseNum.toString();
    for(let i=0; i< stringNum.length; i++){
    let reversed = parseInt(stringNum[i])
    console.log(reversed);
    }

  • @muralivelayudam8079
    @muralivelayudam8079 2 роки тому

    let num = 564782
    let num2 = 0
    while ( num > 0 ) {
    console.log(num % 10 );
    num = parseInt(num / 10 )
    num2 = num
    }

  • @_dipakwagh_
    @_dipakwagh_ 3 роки тому +1

    Do while loop

  • @vaibhavbhatnagar3739
    @vaibhavbhatnagar3739 3 роки тому

    Sir what software you used edit video

  • @anandjha101
    @anandjha101 3 роки тому

    I have deleted node js and I know c++ so I answered questions answer in c++
    #include
    int main(int argc, char *argv[])
    {
    int num=252257;
    int num2=1;
    while(num>0){
    int lastDigit=num%10;
    num2=num2*10+lastDigit;
    num/=10;
    }
    std::cout

  • @sirojohnodilla9990
    @sirojohnodilla9990 Рік тому

    let num = 12345
    let digit = 0
    let reversedDigit = ""
    while(num > 0){
    digit = num % 10
    num = parseInt(num / 10)
    reversedDigit = reversedDigit + String(digit)
    }
    console.log(`The reverse number is:
    ${reversedDigit}`)

  • @sivanms918
    @sivanms918 Рік тому

    Anna vedios continue chey anna..🥲

  • @saicharan1540
    @saicharan1540 2 роки тому +2

    **Not the assignment** splitting the number in the same order not in the reverse order as shown in the video.
    let r=564782;
    t=100000;
    while(r>0)
    {
    a=parseInt(r/t);
    k=parseInt(r%t);
    console.log(a);
    t=t/10;
    r=k;
    }

    • @vinaykumarpunna
      @vinaykumarpunna Рік тому +1

      this is the best method, i have also doing this straight numbers in same orders. thanks for the code.

  • @solomonnartey2041
    @solomonnartey2041 Рік тому

    let num = 123456
    for(;num>0;)
    {
    console.log(num%10)
    num = parseInt(num /10)
    }
    The for loop still woked

  • @sivasaran4
    @sivasaran4 3 роки тому

    I want to know one thing even without let why js works

  • @pranaythanneru4924
    @pranaythanneru4924 Рік тому

    The reverse of the given Number code:
    let num=564782
    let Str=""
    while(num>0){
    Str+=String(num%10)
    num=parseInt(num/10)
    }
    console.log(Str)

  • @smarakdey3739
    @smarakdey3739 2 роки тому

    let num =123456;
    let num2=0;
    while(num>0)
    {
    let rem = num%10;
    num2 = num2*10+rem;
    num = parseInt(num/10);
    }
    console.log(num2);

  • @vinaykumarmb9125
    @vinaykumarmb9125 3 роки тому

    Nice your explanation is amazing sir, and am a fan of you.

  • @mukeshkumarproglint3869
    @mukeshkumarproglint3869 2 роки тому

    let num = 123456;
    let num2 = 0;
    while(num>0){
    q = num / 10;
    r = num % 10;
    num = parseInt(q);
    num2 = (num2*10) + r;
    }
    console.log(num2)

  • @dataisbeauty5512
    @dataisbeauty5512 3 роки тому +1

    Hi my friend

  • @InfoTrickyOfficial
    @InfoTrickyOfficial 3 роки тому +7

    "Yesterday is history".
    "Tomorrow is mystery".
    "Today is a gift ".
    "That's why is called present😎✌️🤟"

  • @VamsiKrishna-ol3um
    @VamsiKrishna-ol3um 3 роки тому

    Very very very nice bro

  • @mookiewookie7444
    @mookiewookie7444 2 роки тому

    Good stuff

  • @barbarasanchezvasquez2242
    @barbarasanchezvasquez2242 2 роки тому

    Thanks.

  • @afisndrivs4647
    @afisndrivs4647 2 роки тому

    I mean bro you're just cool

  • @tejasrao3559
    @tejasrao3559 3 роки тому

    Super 👍

  • @saimahesh1093
    @saimahesh1093 2 роки тому +2

    let num = 123456789
    let num2 = ""
    while(num>0){
    output = String(num%10)
    num2 = num2 + output
    num = parseInt(num/10)
    }
    console.log(num2)

  • @dataisbeauty5512
    @dataisbeauty5512 3 роки тому +1

    1st view and comment

  • @coolgirlsharu
    @coolgirlsharu 3 роки тому

    Ist viewer and first liker

  • @whathuh6965
    @whathuh6965 10 місяців тому +1

    Your examples in this presentation are just too complicated. Keep it simple man.

  • @AyushGupta29164
    @AyushGupta29164 2 місяці тому

    hindi bolo

  • @arnabnandi2009
    @arnabnandi2009 3 роки тому

    num = 1234
    let reverse = 0
    while (num>0)
    {
    reverse = reverse*10+(num%10);
    num = parseInt(num / 10);
    }
    console.log(reverse);

  • @shimaaiblassi736
    @shimaaiblassi736 3 роки тому

    does anyone know why
    console.log(num%10) print 6?

    • @sudarshansharma2896
      @sudarshansharma2896 2 роки тому +1

      because % returns the remainder value so, when you do 123456 / 10, remainder would be 6.

  • @ngawangtashi326
    @ngawangtashi326 Рік тому

    let num1 = 28405
    let num2 = 0
    while(num1>0){
    num2 = num2*10 + num1%10
    console.log(num1%10);
    num1 = parseInt(num1/10)
    }
    console.log(num2);

  • @Ruban_Sn
    @Ruban_Sn Рік тому

    let num = 16548765412;
    let arr = [];
    let q = 1;
    while(q>=1)
    {
    r = num % 10;
    q = num / 10;
    num=Math.floor(q);
    arr.push(r)
    }
    len = arr.length
    while(len>=0)
    {
    console.log(arr[len])
    len--
    }

  • @danvathdarshan1426
    @danvathdarshan1426 3 місяці тому

    for (let i = 1; i

  • @avirajsdiary
    @avirajsdiary 3 роки тому

    for(let i=1, i

  • @PR-kq3px
    @PR-kq3px 3 роки тому

    let newNum = 0;
    let num = 1234;
    while (num > 0) {
    newNum = (num % 10) + (newNum * 10);
    num = parseInt(num / 10);
    }
    console.log(newNum)

  • @chandrareddykarri6277
    @chandrareddykarri6277 2 роки тому

    for(let i=1;i

  • @ImmanuelRodrigues-c8z
    @ImmanuelRodrigues-c8z Місяць тому

    let num = 1
    for(let i=1;i

  • @kumarankaushal2185
    @kumarankaushal2185 2 роки тому

    for(let x= 0; x

  • @sirojohnodilla9990
    @sirojohnodilla9990 Рік тому

    for(let i = 1; i

  • @sodummahesh888
    @sodummahesh888 6 місяців тому

    for(i=1;i

  • @jayanthreddy7886
    @jayanthreddy7886 Рік тому

    for (i = 1; i

  • @olonisaiyeclementina9266
    @olonisaiyeclementina9266 Рік тому

    for (let i = 1; i

  • @mishuuuu__2105
    @mishuuuu__2105 2 роки тому

    for odd numbers
    for (let i = 0; i

  • @arashautomationlab9088
    @arashautomationlab9088 2 роки тому

    for(let i = 0; i

  • @maheshreddyjanga7837
    @maheshreddyjanga7837 Рік тому

    let num=1234;
    let sum=0;
    let rem=0;
    while(num>0)
    {
    rem=num%10;
    sum=sum*10+rem;
    num=num/10;
    }
    console.log(sum); //4321

  • @okechirichard7259
    @okechirichard7259 Рік тому

    for (let i = 1; i