#12 Conditional Statements If Else in JavaScript

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

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

  • @srilakshmim2615
    @srilakshmim2615 Год назад +10

    n=4
    If(n%2==0)
    console. log(evennumber) ;
    Else if(n%2==1)
    console. log( odd number) ;
    Else
    Console(end the program)

  • @kalyanimathur5423
    @kalyanimathur5423 Год назад

    Timestamp 12:00
    Checking if number is odd or even:
    let num = 232;
    let result = num % 2 ;
    if (result ===0){
    console.log("num is even")}
    else console.log("num is odd")
    // output: num is even

  • @sigmatronX
    @sigmatronX 2 года назад +1

    FInding if a number is Even or Odd , time stamp 12:00
    function oddEven(num) {
    if(num % 2 === 0) {
    num = 'even';
    }else {
    num = 'odd';
    }
    return num;
    }
    console.log(oddEven(4));

  • @TomDoesTech
    @TomDoesTech 3 года назад +5

    The ternary operator would be a nice addition to learning how if-else statements work.

  • @s.m.sazidarman2252
    @s.m.sazidarman2252 3 года назад +13

    // Given assignment
    let num1 = 3
    if ((num1 % 2) == 0) {
    console.log("num1 is even")
    } else {
    console.log("num1 is odd")
    }

    • @teluskosupport1
      @teluskosupport1 Год назад +1

      correct but use semicolon after every statement

  • @CultOfJ
    @CultOfJ 3 года назад +3

    Wow sir you finally changed the contrast thank you soooooo much❤️ we love your content👍

  • @ZeenHealthHolistic
    @ZeenHealthHolistic 3 года назад +3

    Question for Video length 9:20 minutes.. The logical operator to you use would be &&

    • @teluskosupport1
      @teluskosupport1 Год назад

      //Logical operators are used to determine the logic between variables or values.
      /*
      Operator Description
      && logical and
      || logical or
      ! logical not
      */

  • @dhruvpatel2067
    @dhruvpatel2067 3 года назад +1

    9:21 logical AND(&& )

  • @martinintilt1783
    @martinintilt1783 Год назад

    5:35 is Eye Opening to me 😍😍😍😍.
    9:25 its very tough for me to guess 😞

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

    You made if else conditions complicated for beginners in other videos its showcased very simply and clearly.

  • @sahul._
    @sahul._ 3 года назад

    Clean and nice
    let n = 12;
    if(n/2 === 0){
    console.log("even")
    };
    console.log("odd")

    • @teluskosupport1
      @teluskosupport1 Год назад +1

      let x=4;
      if(x%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }
      there is difference between % and / operators. % modulas to find remainder and / division to find result after simple division in maths.

  • @ImKayori
    @ImKayori Год назад

    "yeee" lololol IDK why that made me laugh so hard. I love the way you teach....thank you so much.

  • @LimitlessLivingDiscovery
    @LimitlessLivingDiscovery День назад

    Impressed Sir here is your assignment
    let num1=25
    if(num1%2==0){
    console.log('(num1 is even');
    }
    else{
    console.log('num1 is odd');
    }

  • @iIrfanhussain
    @iIrfanhussain Год назад

    9:12 AND operator

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

    very very basics that no one is telling but are. that's awesome!! plz make more videos for this playlist

    • @chetanram797
      @chetanram797 Год назад

      @@user-ii2ek8hf1r if teacher call something to student out of love.
      Just take it with joy 😊. Or you can simply unsubscribe.

  • @Sayem-y4h
    @Sayem-y4h Год назад

    9:21 I should use and "&&" operator

  • @Team3-h9f
    @Team3-h9f Год назад

    AND(&) operator

  • @gowripriya8430
    @gowripriya8430 Год назад +7

    let a = prompt("enter a value");
    if(a%2 == 0){
    console.log("even");
    }
    else{
    console.log("odd");
    }

  • @aameenpatel7031
    @aameenpatel7031 3 года назад +6

    let a=10;
    if(a%2==0)
    console.log(a,'is a even number')
    else
    console.log(a," is a odd number.")

    • @Namakarana
      @Namakarana 3 года назад +1

      Let a =int(input("enter a number u needed"))

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

      It is === not ==

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

      @@Namakarana but its also work

  • @vanshrewaskar5119
    @vanshrewaskar5119 3 года назад +2

    Are you going to create videos on C language too, it will be very helpful for me and my college mate, cause I have problem to learn it, and the way you taught java last Sunday was phenomenal

  • @mehulbisht9708
    @mehulbisht9708 3 года назад +5

    Sir I know the series is very helpful and informative but there is a huge delay in videos. For completing the actual js client part that the series aimed at, it will take 4-5 months i think, please consider that Sir :)

  • @bonnyrogny241
    @bonnyrogny241 Год назад

    9:25 AND &&

  • @okechirichard7259
    @okechirichard7259 Год назад

    I found a simpler way, you can only compare the remaining two values:
    let num1 = 15;
    let num2 = 10;
    let num3 = 20;
    if (num1 > num2 && num1 > num3) {
    console.log("num1 is greatest");
    }
    else if (num2 > num3) {
    console.log("num2 is greatest");
    }
    else {
    console.log("num3 is greatest")
    }
    console.log("Exit")

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

    at 9.18 the operator we use is &&

  • @ishab2434
    @ishab2434 Год назад

    4:35 i copied it exactly same and checked it multiple time but num1 is greater is not printing and it say process finished with exit code 0

    • @ishab2434
      @ishab2434 Год назад

      it worked when i put = with >

  • @isiborjohnson3820
    @isiborjohnson3820 Год назад

    Let num = 15;
    If(num % 2 === 1){console.log(‘num is an odd number’)}
    Else{console.log(‘num is an even number);}

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

    "Java Script say:its your choice! " :D :D
    3:42

  • @maheshchaubey3460
    @maheshchaubey3460 3 года назад +2

    If(n%2==0) //We are checking Number is divided exactly by 2 or not
    console.log("even");
    else
    console.log("odd");

    • @theCodesConnection
      @theCodesConnection 3 года назад +1

      if condition is true then it should print even, your console.log needs to be swapped

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

      @@theCodesConnection thanks👍 updated

    • @teluskosupport1
      @teluskosupport1 Год назад

      correct but for better result remove unintentional case
      // function to check even or odd number
      function evenOdd(num){
      //remove unintentional case
      if(typeof num === "number"&&Number.isInteger(num))
      {
      if(num%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }
      }
      else{
      console.log("not a integer number");
      }
      }

  • @nayeemarefin2217
    @nayeemarefin2217 Год назад

    So if num1 > num2 is the condition but it is not satisfied then we can use both a console.log after } or else and console.log with a new set of 2 curly brackets?

  • @sanoojkavungal110
    @sanoojkavungal110 Год назад

    i learned basics of c already, js is heaven comparably to c 😹

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

    I love Javascript its like reading code from wordpress and after Js, if U know what I mean, U will say,omg f wp who can working with that, u havnt freedom, with JS U have freedom enough.
    I start love JS .
    Its my secend best friend :P

  • @favourebube2965
    @favourebube2965 9 месяцев назад

    my assignment:
    I took hours racking my head on displaying the different variable calculations in a single block, but I couldn't,😉🙂 it was fun.
    let num1 = 10 / 2;
    let num2 = 9 / 2;
    let num3 = 7 / 2;
    if (num1 % 1) {
    console.log("odd");
    }
    else {
    console.log("even");
    };
    if (num2 % 1) {
    console.log("odd");
    }
    else {
    console.log("even");
    };
    if (num3 % 1) {
    console.log("odd");
    }
    else {
    console.log("even");
    };

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

    The number is divided by 2 that is even or its odd number
    If the condition num1%2==0 that is even or that is odd number

  • @Ananthasri-k2r
    @Ananthasri-k2r Год назад

    The answer is:
    let num = 10;
    if(num % 2 == 0){
    console.log('The number is even number')
    }
    else{
    console.log('The number is odd number')
    }

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

    I/p:-
    Let n=12;
    If(n%2==0)
    {
    Console.log(number is even);
    }
    else
    {
    console.log(number is odd);
    }
    O/p:-number is even.

    • @teluskosupport1
      @teluskosupport1 Год назад

      function oddEven(num) {
      if(num % 2 === 0) {
      num = 'even';
      }else {
      num = 'odd';
      }
      return num;
      }
      console.log(oddEven(4));
      you should create function for any number

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

    Thank you very much

  • @ansreenu4001
    @ansreenu4001 Год назад

    really enjoying

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

    Sir it would really be halpful if u start a tutorial on Data science

  • @saminenichandana5707
    @saminenichandana5707 3 года назад +12

    I guess I'm the 1st commenter

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

    thank you very much!

  • @manojpotdar2314
    @manojpotdar2314 3 года назад +1

    I m bit confused about what lang to chooce

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

    Assignment
    let num1 = 2
    if (num1 % 2 == 0) {
    console.log("num1 is even")
    }
    else {
    console.log("num1 is odd")
    }

    • @teluskosupport1
      @teluskosupport1 Год назад

      nice ,
      let num=4.5;
      if(typeof num === "number"&&Number.isInteger(num))
      {if(num%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }}
      else{
      console.log("not a integer number");
      }
      suppose user can give num is string or float then how to deal for good programming practice remove unintentional cases

  • @LobuinJohn
    @LobuinJohn 9 месяцев назад

    whats the difference between system.out.printIn() and console.log()

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

    let a=3; // to check whether number is odd or even
    if(a%2===0)
    console.log("the number is even");
    else
    console.log("the number is odd");

  • @m9h0z4
    @m9h0z4 Год назад

    Let num = 5;
    Let result= num % 2;
    If (result===0)
    Console.log(num, "is an even number");
    else
    Console.log(num, "is an odd number");

  • @raakshas5547
    @raakshas5547 2 года назад +2

    if(num1%2==0){
    console.log("Its an even number");
    }
    else{
    console.log("Its a odd number");
    }

  • @manojpotdar2314
    @manojpotdar2314 3 года назад +1

    I am a mechanical engg with zero programming kngle

  • @padmam8402
    @padmam8402 Год назад

    Finding number is even or odd.
    Let a=prompt("enter a value")
    If(a%2===0){
    Console.log("even");
    }else{
    Console.log("odd");
    }

    • @wellingtonshava-mhofu4208
      @wellingtonshava-mhofu4208 Год назад +1

      prompt is saying "not defined", using number instead of prompt got me the result perfectly.

  • @夜神月-l8q
    @夜神月-l8q 2 года назад

    // sir ur example has a bug if 2 no. r equal then??
    // Assignment
    let num = 8;
    if (num%2===0){
    console.log("number is even")
    }
    else{
    console.log("number is odd")
    }

  • @gaganbedi4332
    @gaganbedi4332 2 года назад +1

    let num=5
    if (num%2)
    console.log("Number is odd")
    else
    console.log("Number is even")

    • @teluskosupport1
      @teluskosupport1 Год назад

      working fine
      you can use like this as
      let num=4;
      if(typeof num === "number"&&Number.isInteger(num))
      {if(num%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }}
      else{
      console.log("not a integer number");
      }

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

    Hello Sir,
    I tried this on my console and what I observed that if I put ; at the end of if (result); then its still showing the output as num1 is greater though it is false. kindly suggest why this is happening.
    let num1 = 3;
    let num2 = 4;
    let result = num1 > num2;
    if(result);
    console.log("Num 1 is greater");
    console.log("Bye..");
    output :
    [Running] node "c:\Users\Desktop\js\IfElse.js"
    Num 1 is greater
    Bye..
    [Done] exited with code=0 in 0.166 seconds

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

      Remove al ; semicolon,this will help

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

      After if (result) remove ;
      You are ending the if statement there itself if you keep ;

    • @teluskosupport1
      @teluskosupport1 Год назад +1

      let num1 = 3;
      let num2 = 4;
      let result = num1 > num2;
      if(result); //

  • @danvathdarshan1426
    @danvathdarshan1426 3 месяца назад

    if (num1 % 2 === 0){
    console.log("Even Number")
    }
    else
    console.log("Odd")
    if (num2 % 2 === 0){
    console.log("Even Number")
    }

    else
    console.log("Odd")
    if (num3 % 2 === 0){
    console.log("Even Number")
    }
    else
    console.log("Odd")
    Sir, I created a separate if else for each input

  • @SaiRam-qt1yq
    @SaiRam-qt1yq 3 года назад

    let num1 = 86
    if (num1 % 2 == 0){
    console.log("the given number is even")
    }
    else
    console.log("the given number is odd")
    console.log("Bye...")

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

    let x = 3;
    let y = 2;
    let result = x%y;
    if (result === 0)
    console.log(" Number is even")
    else
    console.log("Number is odd")

    • @teluskosupport1
      @teluskosupport1 Год назад

      correct to check even and odd but not good way to write you declare lots of variable for simple work.
      let x=4;
      if(x%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }

  • @robertmaina337
    @robertmaina337 Год назад

    let num = parseInt(prompt("Enter a number: "));
    if (number %2 == 0)
    console.log("Number is Even");
    else
    console.log("Number is Odd');

    • @kalyanimathur5423
      @kalyanimathur5423 Год назад

      when I try this it gives me an error saying "ReferenceError: prompt is not defined". even though I replaced "Enter a number: " with 8(any number for example) in the first line. Is prompt supposed to be an in-built JS thing or do I have to define prompt like we define any variable?

  • @ansafnisam2443
    @ansafnisam2443 3 года назад +1

    I can only imagine how hard it is to explain things for a beginner to understand when you have explained same concepts earlier in other videos.
    I would have always be like: 'As I said earlier....'

  • @Maheshkumar_ch
    @Maheshkumar_ch 8 месяцев назад

    //Assignment
    let num=99;
    if(num%2==0){
    console.log("num is even number")
    }
    else{
    console.log("num is odd number");
    }

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

    How to give functions in conditions

    • @teluskosupport1
      @teluskosupport1 Год назад

      function evenOdd(num){
      //remove unintentional case
      if(typeof num === "number"&&Number.isInteger(num))
      {if(num%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }}
      else{
      console.log("not a integer number");
      }
      }
      this way

  • @Ankit-zi3yf
    @Ankit-zi3yf 3 года назад

    Sir but when I try using else it says unexpected token

    • @teluskosupport1
      @teluskosupport1 Год назад

      Sometimes, you leave out brackets around if statements:
      function round(n, upperBound, lowerBound) {
      if (n > upperBound) || (n < lowerBound) { // Not enough brackets here!

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

    Thanks.

  • @padminicp2562
    @padminicp2562 7 месяцев назад

    Find out given number is even or off
    Let num = 2
    If (num%2 === 0) {
    Console.log("given number is even");
    }//% says 2/2 remainer is 0
    else {
    Console.log("given number is off");
    }

  • @babayaga6172
    @babayaga6172 3 года назад +1

    // check no is either odd or even
    let x = 146;
    if(x%2===0){
    console.log(x is even)
    }
    else{
    console.log(x is odd)
    }
    // output: x is even

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

    @9:18
    AND Operator
    &&

    • @teluskosupport1
      @teluskosupport1 Год назад

      its a logical operator check two conditon is true or false if both are true then true if atleast one of them is false then statement is flase

  • @sirojohnodilla9990
    @sirojohnodilla9990 Год назад

    let number = 8
    if(number % 2 == 0){
    console.log("number is even")
    } else{
    console.log("number is odd")
    }

  • @syedareebhussain8436
    @syedareebhussain8436 Год назад

    //Task
    let num1 = 10,
    num2 = 4,
    num3 = 7;
    function isCheck(ele) {
    return ele % 2 == 0;
    }
    isCheck(num1) ? console.log("Even") : console.log("Odd");//Even
    isCheck(num2) ? console.log("Even") : console.log("Odd");//Even
    isCheck(num3) ? console.log("Even") : console.log("Odd");//Odd

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

    Perfect vscode them

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

    // it is a even or odd number
    let num = 145
    if (num%2==0){
    console.log("it is a even number ", num)
    }
    else{
    console.log("it is a odd number", num)
    }

  • @manojpotdar2314
    @manojpotdar2314 3 года назад +1

    Hello sir

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

    Semi colon (;) seems just a habit of java developer.

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

    if thee number is ever or odd
    let num = 54
    if (num%2 === 0){
    console.log("num is even");
    }else {
    console.log("num is odd");
    }

  • @hunter982
    @hunter982 Год назад

    And opeartor

  • @yellayiaruna6170
    @yellayiaruna6170 3 года назад +1

    Hi Naveen,
    What if, I will write code like this:
    let num1 = 9;
    let num2 = 9;
    let result = num1 > num2;
    if (result){
    console.log("num1 is greater");
    }
    else
    {
    console.log("num2 is greater");
    }
    Here the output is showing num2 is greater, could you explain it?

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

      It's completely false case

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

      Both are equal num1==num2

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

      u should put num1 == num2 since both the numbers are the same

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

      in the " If " statement, you check that " num1 greater than num2 ". As all of us know, 9 is not greater than 9. So it returns false and then it goes to the else block, because your comparison returns false. The " else " block doesn't means the opposite ( greater smaller ) but it means everything which won't be accepted to your comparison

    • @teluskosupport1
      @teluskosupport1 Год назад +1

      you are missing one condition for equality
      if(num1>num2)
      console.log('num1 is greater than num2');
      else if(num1===num2)
      console.log('num1 is equal to num2');
      else
      console.log('num1 is less than num2');

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

    and operator

  • @venkatkvr4468
    @venkatkvr4468 Год назад

    let x = 10;
    let result = x % 2;
    if(result)
    console.log("x is odd");
    else
    console.log("x is even");

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

    let num = 1;
    if(num%2==0)
    {
    console.log("num is even");
    }
    else{
    console.log("the num is odd");
    }

  • @1conscience0dimension
    @1conscience0dimension 3 года назад

    not a good practice but an unnecessary practice. you can put semi columns in python too :)

    • @teluskosupport1
      @teluskosupport1 Год назад

      // why use of semicolon is important in javascript ?
      // semicolon is used to separate the statements in javascript and avoid the errors in javascript that are not expected by the user .
      since, javascript doesnot generate any error and if we use semicolon it prevent our code from error

  • @babyrhymes4u
    @babyrhymes4u 11 месяцев назад

    let num1 = 6;
    if (num1 % 2 === 0) {
    console.log(num1 + " is even");
    } else {
    console.log(num1 + " is odd");
    }

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

    Is using brackets even if you have 1 statement in the block best practice?

    • @teluskosupport1
      @teluskosupport1 Год назад

      yes, best practice use dry principle and use brackets and semicolon .

  • @e.cjeyaruban4753
    @e.cjeyaruban4753 3 года назад

    and operator(&&)

    • @teluskosupport1
      @teluskosupport1 Год назад

      its a logical operator to add two condition and check both are true or not

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

    //Assignment
    let n = 30
    if (n%2==0) {
    console.log(n,'is an even number.');
    } else {
    console.log(n, 'is an odd number.');
    }

  • @joshuaomotosho7463
    @joshuaomotosho7463 10 месяцев назад

    The if else is not clear sir, it's complex

  • @ItsRam299
    @ItsRam299 Год назад

    x = 10;
    y = 2;
    if (x%y == 0){
    console.log('even')
    }
    else{
    console.log('odd')
    }

  • @kailashmedavarapu9859
    @kailashmedavarapu9859 3 года назад +1

    1st view and 1st like

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

    Answer of the Assignment :
    let num = 4
    num%2==0?console.log("Even"):console.log("Odd")

  • @GamingShitpost
    @GamingShitpost 2 года назад +1

    let num1 = 10;
    let num2 = 11;
    let num3 = 11;
    if(num1 > num2 && num1 > num3){
    console.log("num1 is greatest");
    }
    else if(num2 > num1 && num2 > num3){
    console.log("num2 is greatest");
    }
    else{
    console.log("num3 is greatest");
    }
    console.log("Code finished");
    num3 is greatest?

    • @teluskosupport1
      @teluskosupport1 Год назад

      since num2 is equal to num3 that's why else if condition fail and condition come to else part now use like that else if(num2>=num1&&num2>=num3)
      console.log("num2 is greatest");

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

    i like your series in general sir, but you should have told us how to take inputs before gioin into these stuff.... is FRUSTRATING not knowing how to get input and doing these operations , it makes programming boring, i already have experience in python

  • @_parm_
    @_parm_ 10 месяцев назад

    9:23 &&

  • @sivasaran4
    @sivasaran4 3 года назад +1

    let x=8
    if(x%2==0)
    console.log("even")
    else
    console.log("odd")
    console.log("Happy coding")
    /* 💻🖥📱*/

  • @wellingtonshava-mhofu4208
    @wellingtonshava-mhofu4208 Год назад

    let a = number ("17");
    if(a%2===0){
    console.log("even");
    }
    else{
    console.log("odd");
    {

  • @aryan4000
    @aryan4000 3 года назад +1

    num = 19;
    if (num%2==0) {
    console.log("the number is even");
    }
    else{
    console.log("the number is odd");
    }

  • @shaurya4ssvb816
    @shaurya4ssvb816 3 года назад +1

    Elif

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

    AND

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

    🙏👍

  • @naidutulasi8954
    @naidutulasi8954 Год назад

    And

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

    let num = 10;
    if (num%2===0) {
    console.log(String(num) +' '+'is an even number');
    }
    else{
    console.log(String(num) +' '+'is an odd number');
    }

  • @firefree3186
    @firefree3186 6 месяцев назад

    default

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

    let num1=5
    if((num1)%2==0)
    console.log('number is even');
    else
    console.log('number is odd');

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

    If(n%2)
    console.log("odd");
    else
    console.log("even");

    • @teluskosupport1
      @teluskosupport1 Год назад

      working fine but
      you can use like that also
      for better result
      this conditon fail for string and float
      use like this
      if(typeof num === "number"&&Number.isInteger(num))
      {if(num%2===0){
      console.log("even");
      }
      else{
      console.log("odd");
      }}
      else{
      console.log("not a integer number");
      }

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

    Dude, improve your accent when talking in english

  • @souravmandal3868
    @souravmandal3868 Год назад

    let num = 69;
    if (num & 1)
    console.log ("The number is odd!");
    else
    console.log ("The number is even");