Тёмный

#12 Conditional Statements If Else in JavaScript 

Telusko
Подписаться 2,4 млн
Просмотров 87 тыс.
50% 1

If else
else if
else
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
Discord : / discord
More Learning :
Java - bit.ly/3xleOA2
Python :- bit.ly/3H0DYHx
Django :- bit.ly/3awMaD8
Spring Boot :- bit.ly/3aucCgB
Spring Framework :- bit.ly/3GRfxwe
Servlet & JSP :- bit.ly/3mh5CGz
Hibernate Tutorial :- bit.ly/3NWAKah
Rest API | Web Service Tutorial :- bit.ly/38RJCiy
Git :- bit.ly/3NUHB3V
JavaScript :- bit.ly/3mkcFys
Kotlin :- bit.ly/3GR2DOG

Наука

Опубликовано:

 

24 май 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 143   
@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)
@CultOfJ
@CultOfJ 3 года назад
Wow sir you finally changed the contrast thank you soooooo much❤️ we love your content👍
@TomDoesTech
@TomDoesTech 3 года назад
The ternary operator would be a nice addition to learning how if-else statements work.
@abhinandtp9048
@abhinandtp9048 Год назад
You made if else conditions complicated for beginners in other videos its showcased very simply and clearly.
@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 11 месяцев назад
@@user-ii2ek8hf1r if teacher call something to student out of love. Just take it with joy 😊. Or you can simply unsubscribe.
@ImKayori
@ImKayori Год назад
"yeee" lololol IDK why that made me laugh so hard. I love the way you teach....thank you so much.
@vanshrewaskar5119
@vanshrewaskar5119 3 года назад
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
@sahul._
@sahul._ 3 года назад
Clean and nice let n = 12; if(n/2 === 0){ console.log("even") }; console.log("odd")
@teluskosupport1
@teluskosupport1 Год назад
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.
@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?
@balajimelagiri2937
@balajimelagiri2937 3 года назад
Sir it would really be halpful if u start a tutorial on Data science
@diaviekone4720
@diaviekone4720 Год назад
thank you very much!
@shirkhanaslanzade1850
@shirkhanaslanzade1850 2 года назад
Thank you very much
@ansreenu4001
@ansreenu4001 Год назад
really enjoying
@RamuPoojari
@RamuPoojari Год назад
at 9.18 the operator we use is &&
@mehulbisht9708
@mehulbisht9708 3 года назад
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 :)
@sigmatronX
@sigmatronX Год назад
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));
@teluskosupport1
@teluskosupport1 Год назад
absolutely correct
@dhruvpatel2067
@dhruvpatel2067 3 года назад
9:21 logical AND(&& )
@martinintilt1783
@martinintilt1783 9 месяцев назад
5:35 is Eye Opening to me 😍😍😍😍. 9:25 its very tough for me to guess 😞
@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
@kalyanimathur5423
@kalyanimathur5423 8 месяцев назад
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
@asifbasham570
@asifbasham570 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 */
@user-sb9qp5xm7n
@user-sb9qp5xm7n 10 месяцев назад
9:21 I should use and "&&" operator
@barbarasanchezvasquez2242
@barbarasanchezvasquez2242 2 года назад
Thanks.
@sanoojkavungal110
@sanoojkavungal110 Год назад
i learned basics of c already, js is heaven comparably to c 😹
@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
@saminenichandana5707
@saminenichandana5707 3 года назад
I guess I'm the 1st commenter
@user-xq6ol2un7z
@user-xq6ol2un7z 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") }
@maheshchaubey3460
@maheshchaubey3460 3 года назад
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 года назад
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"); } }
@favourebube2965
@favourebube2965 4 месяца назад
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"); };
@ravi_sorathiya
@ravi_sorathiya 3 года назад
Perfect vscode them
@suchakbarik-0812
@suchakbarik-0812 2 года назад
What is the name of this theme?
@tomasmatusek6292
@tomasmatusek6292 3 года назад
"Java Script say:its your choice! " :D :D 3:42
@okechirichard7259
@okechirichard7259 7 месяцев назад
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")
@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");
@teluskosupport1
@teluskosupport1 Год назад
correct to check
@iIrfanhussain
@iIrfanhussain Год назад
9:12 AND operator
@isiborjohnson3820
@isiborjohnson3820 Год назад
Let num = 15; If(num % 2 === 1){console.log(‘num is an odd number’)} Else{console.log(‘num is an even number);}
@raakshas5547
@raakshas5547 2 года назад
if(num1%2==0){ console.log("Its an even number"); } else{ console.log("Its a odd number"); }
@tabindanaiyer5172
@tabindanaiyer5172 2 года назад
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
@user-of3dy4li4s
@user-of3dy4li4s 4 месяца назад
whats the difference between system.out.printIn() and console.log()
@ansafnisam2443
@ansafnisam2443 3 года назад
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....'
@bonnyrogny241
@bonnyrogny241 11 месяцев назад
9:25 AND &&
@s.m.sazidarman2252
@s.m.sazidarman2252 3 года назад
// Given assignment let num1 = 3 if ((num1 % 2) == 0) { console.log("num1 is even") } else { console.log("num1 is odd") }
@teluskosupport1
@teluskosupport1 Год назад
correct but use semicolon after every statement
@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 Год назад
prompt is saying "not defined", using number instead of prompt got me the result perfectly.
@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
@gowripriya8430
@gowripriya8430 Год назад
let a = prompt("enter a value"); if(a%2 == 0){ console.log("even"); } else{ console.log("odd"); }
@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 >
@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 8 месяцев назад
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?
@gaganbedi4332
@gaganbedi4332 2 года назад
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"); }
@user-vb3lb9mj7i
@user-vb3lb9mj7i 11 месяцев назад
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') }
@shashavsharma3069
@shashavsharma3069 Год назад
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"); }
@prafulk2003
@prafulk2003 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 Год назад
let num1 = 3; let num2 = 4; let result = num1 > num2; if(result); //
@SaiRam-qt1yq
@SaiRam-qt1yq 2 года назад
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...")
@aameenpatel7031
@aameenpatel7031 3 года назад
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 года назад
Let a =int(input("enter a number u needed"))
@Namakarana
@Namakarana 3 года назад
It is === not ==
@aameenpatel7031
@aameenpatel7031 3 года назад
@@Namakarana but its also work
@manojpotdar2314
@manojpotdar2314 3 года назад
I am a mechanical engg with zero programming kngle
@ishakshatriya3740
@ishakshatriya3740 2 года назад
And operator
@himanshuchoudhary4323
@himanshuchoudhary4323 3 года назад
and operator
@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 .
@hunter982
@hunter982 9 месяцев назад
And opeartor
@m9h0z4
@m9h0z4 6 месяцев назад
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");
@mrrishiraj88
@mrrishiraj88 3 года назад
🙏👍
@manojpotdar2314
@manojpotdar2314 3 года назад
I m bit confused about what lang to chooce
@teluskosupport1
@teluskosupport1 Год назад
i sugggest choose java and javascript both.
@Mahesh_22_Dec
@Mahesh_22_Dec 3 месяца назад
//Assignment let num=99; if(num%2==0){ console.log("num is even number") } else{ console.log("num is odd number"); }
@Ankit-zi3yf
@Ankit-zi3yf 2 года назад
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!
@e.cjeyaruban4753
@e.cjeyaruban4753 3 года назад
and operator(&&)
@teluskosupport1
@teluskosupport1 Год назад
its a logical operator to add two condition and check both are true or not
@sunnyshaik7399
@sunnyshaik7399 2 года назад
// 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) }
@boralugoda.
@boralugoda. 3 года назад
1 st view and comment😋
@yellayiaruna6170
@yellayiaruna6170 2 года назад
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 2 года назад
It's completely false case
@badrinadhyt6478
@badrinadhyt6478 2 года назад
Both are equal num1==num2
@Bulldog01234
@Bulldog01234 2 года назад
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 Год назад
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');
@manojpotdar2314
@manojpotdar2314 3 года назад
Hello sir
@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
@sirojohnodilla9990
@sirojohnodilla9990 Год назад
let number = 8 if(number % 2 == 0){ console.log("number is even") } else{ console.log("number is odd") }
@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"); }
@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
@prasadbarhate9152
@prasadbarhate9152 3 года назад
let num = 1; if(num%2==0) { console.log("num is even"); } else{ console.log("the num is odd"); }
@user-hg8zt8fs2y
@user-hg8zt8fs2y 9 месяцев назад
AND(&) operator
@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
@NareshShewakramani
@NareshShewakramani 2 года назад
Semi colon (;) seems just a habit of java developer.
@padminicp2562
@padminicp2562 2 месяца назад
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"); }
@padminicp2562
@padminicp2562 2 месяца назад
Typo it's odd
@venkatkvr4468
@venkatkvr4468 Год назад
let x = 10; let result = x % 2; if(result) console.log("x is odd"); else console.log("x is even");
@babyrhymes4u
@babyrhymes4u 6 месяцев назад
let num1 = 6; if (num1 % 2 === 0) { console.log(num1 + " is even"); } else { console.log(num1 + " is odd"); }
@babayaga6172
@babayaga6172 3 года назад
// 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
@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.'); }
@ItsRam299
@ItsRam299 Год назад
x = 10; y = 2; if (x%y == 0){ console.log('even') } else{ console.log('odd') }
@kailashmedavarapu9859
@kailashmedavarapu9859 3 года назад
1st view and 1st like
@naidutulasi8954
@naidutulasi8954 10 месяцев назад
And
@akashshukla378
@akashshukla378 2 года назад
AND
@aryan4000
@aryan4000 3 года назад
num = 19; if (num%2==0) { console.log("the number is even"); } else{ console.log("the number is odd"); }
@shaurya4ssvb816
@shaurya4ssvb816 3 года назад
Elif
@tgturbo7958
@tgturbo7958 Год назад
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_ 5 месяцев назад
9:23 &&
@joshuaomotosho7463
@joshuaomotosho7463 5 месяцев назад
The if else is not clear sir, it's complex
@wellingtonshava-mhofu4208
@wellingtonshava-mhofu4208 Год назад
let a = number ("17"); if(a%2===0){ console.log("even"); } else{ console.log("odd"); {
@sivasaran4
@sivasaran4 3 года назад
let x=8 if(x%2==0) console.log("even") else console.log("odd") console.log("Happy coding") /* 💻🖥📱*/
@firefree3186
@firefree3186 Месяц назад
default
@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"); }
@brahmamnama8792
@brahmamnama8792 2 года назад
let num1=5 if((num1)%2==0) console.log('number is even'); else console.log('number is odd');
@LoU3107
@LoU3107 3 года назад
Dude, improve your accent when talking in english
@folusoawolola8183
@folusoawolola8183 2 года назад
let num = 10; if (num%2===0) { console.log(String(num) +' '+'is an even number'); } else{ console.log(String(num) +' '+'is an odd number'); }
@syedareebhussain8436
@syedareebhussain8436 9 месяцев назад
//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
@dheerajkashyap7607
@dheerajkashyap7607 Год назад
Answer of the Assignment : let num = 4 num%2==0?console.log("Even"):console.log("Odd")
@souravmandal3868
@souravmandal3868 Год назад
let num = 69; if (num & 1) console.log ("The number is odd!"); else console.log ("The number is even");
@Ahmad-re7xl
@Ahmad-re7xl Год назад
let number = 5 if(number % 2 == 0){ console.log('This number is even.') } else{ console.log('This number is odd.') }
Далее
#13 Ternary Operator in JavaScript
5:02
Просмотров 78 тыс.
why are switch statements so HECKIN fast?
11:03
Просмотров 388 тыс.
FARUX RAIMOV AVJIGA CHIQDI - JAVOHIR🔥
01:01
Просмотров 1,7 млн
Июль в Tanks Blitz
51:46
Просмотров 91 тыс.
The Most Impressive Basketball Moments!
00:36
Просмотров 6 млн
If statements in JavaScript are easy 🤔
15:58
Просмотров 24 тыс.
Array Method filter map reduce
9:35
Просмотров 63 тыс.
The if-else Statement in Python
9:41
Просмотров 17 тыс.
#11 Logical Operators in JavaScript
7:30
Просмотров 69 тыс.
Factorial using Recursion | JavaScript
9:01
Просмотров 39 тыс.
What is JSON ?
11:56
Просмотров 1,1 млн
JavaScript Pro Tips - Code This, NOT That
12:37
Просмотров 2,5 млн
Best mobile of all time💥🗿 [Troll Face]
0:24
Просмотров 2,7 млн
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
Просмотров 168 тыс.