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
@sigmatronX2 жыл бұрын
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 Жыл бұрын
absolutely correct
@TomDoesTech3 жыл бұрын
The ternary operator would be a nice addition to learning how if-else statements work.
@ZeenHealthHolistic3 жыл бұрын
Question for Video length 9:20 minutes.. The logical operator to you use would be &&
@teluskosupport1 Жыл бұрын
//Logical operators are used to determine the logic between variables or values. /* Operator Description && logical and || logical or ! logical not */
@s.m.sazidarman22523 жыл бұрын
// Given assignment let num1 = 3 if ((num1 % 2) == 0) { console.log("num1 is even") } else { console.log("num1 is odd") }
@teluskosupport1 Жыл бұрын
correct but use semicolon after every statement
@abhinandtp90482 жыл бұрын
You made if else conditions complicated for beginners in other videos its showcased very simply and clearly.
@CultOfJ3 жыл бұрын
Wow sir you finally changed the contrast thank you soooooo much❤️ we love your content👍
@dhruvpatel20673 жыл бұрын
9:21 logical AND(&& )
@sahul._3 жыл бұрын
Clean and nice let n = 12; if(n/2 === 0){ console.log("even") }; console.log("odd")
@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.
@ImKayori Жыл бұрын
"yeee" lololol IDK why that made me laugh so hard. I love the way you teach....thank you so much.
@vanshrewaskar51193 жыл бұрын
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
@martinintilt1783 Жыл бұрын
5:35 is Eye Opening to me 😍😍😍😍. 9:25 its very tough for me to guess 😞
@chetanram7972 жыл бұрын
very very basics that no one is telling but are. that's awesome!! plz make more videos for this playlist
@chetanram797 Жыл бұрын
@@user-ii2ek8hf1r if teacher call something to student out of love. Just take it with joy 😊. Or you can simply unsubscribe.
@Sayem-y4h Жыл бұрын
9:21 I should use and "&&" operator
@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")
@mehulbisht97083 жыл бұрын
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 :)
@iIrfanhussain Жыл бұрын
9:12 AND operator
@tomasmatusek62923 жыл бұрын
"Java Script say:its your choice! " :D :D 3:42
@maheshchaubey34603 жыл бұрын
If(n%2==0) //We are checking Number is divided exactly by 2 or not console.log("even"); else console.log("odd");
@theCodesConnection3 жыл бұрын
if condition is true then it should print even, your console.log needs to be swapped
@maheshchaubey34603 жыл бұрын
@@theCodesConnection thanks👍 updated
@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"); } }
@gowripriya8430 Жыл бұрын
let a = prompt("enter a value"); if(a%2 == 0){ console.log("even"); } else{ console.log("odd"); }
@bonnyrogny241 Жыл бұрын
9:25 AND &&
@RamuPoojari2 жыл бұрын
at 9.18 the operator we use is &&
@tomasmatusek62923 жыл бұрын
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
@isiborjohnson3820 Жыл бұрын
Let num = 15; If(num % 2 === 1){console.log(‘num is an odd number’)} Else{console.log(‘num is an even number);}
@sampathkumar56993 жыл бұрын
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 Жыл бұрын
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
@raakshas55472 жыл бұрын
if(num1%2==0){ console.log("Its an even number"); } else{ console.log("Its a odd number"); }
@aameenpatel70313 жыл бұрын
let a=10; if(a%2==0) console.log(a,'is a even number') else console.log(a," is a odd number.")
@Namakarana3 жыл бұрын
Let a =int(input("enter a number u needed"))
@Namakarana3 жыл бұрын
It is === not ==
@aameenpatel70313 жыл бұрын
@@Namakarana but its also work
@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 Жыл бұрын
it worked when i put = with >
@sanoojkavungal110 Жыл бұрын
i learned basics of c already, js is heaven comparably to c 😹
@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");
@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?
@tabindanaiyer51723 жыл бұрын
Assignment let num1 = 2 if (num1 % 2 == 0) { console.log("num1 is even") } else { console.log("num1 is odd") }
@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
@favourebube29659 ай бұрын
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"); };
@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') }
@kanagaraj_p10793 жыл бұрын
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
@balajimelagiri29373 жыл бұрын
Sir it would really be halpful if u start a tutorial on Data science
@shashavsharma30692 жыл бұрын
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 Жыл бұрын
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"); }
@karthikhc89193 жыл бұрын
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 Жыл бұрын
correct to check
@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 Жыл бұрын
prompt is saying "not defined", using number instead of prompt got me the result perfectly.
@manojpotdar23143 жыл бұрын
I am a mechanical engg with zero programming kngle
@夜神月-l8q2 жыл бұрын
// 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") }
@diaviekone47202 жыл бұрын
thank you very much!
@shirkhanaslanzade18503 жыл бұрын
Thank you very much
@LobuinJohn9 ай бұрын
whats the difference between system.out.printIn() and console.log()
@ansreenu4001 Жыл бұрын
really enjoying
@gaganbedi43322 жыл бұрын
let num=5 if (num%2) console.log("Number is odd") else console.log("Number is even")
@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"); }
@SaiRam-qt1yq3 жыл бұрын
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...")
@RandomPKVid2 жыл бұрын
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
@ombrebyaarti30242 жыл бұрын
Remove al ; semicolon,this will help
@praveenjorrigala57312 жыл бұрын
After if (result) remove ; You are ending the if statement there itself if you keep ;
@teluskosupport1 Жыл бұрын
let num1 = 3; let num2 = 4; let result = num1 > num2; if(result); //
@manojpotdar23143 жыл бұрын
I m bit confused about what lang to chooce
@teluskosupport1 Жыл бұрын
i sugggest choose java and javascript both.
@robertmaina337 Жыл бұрын
let num = parseInt(prompt("Enter a number: ")); if (number %2 == 0) console.log("Number is Even"); else console.log("Number is Odd');
@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?
@Maheshkumar_ch8 ай бұрын
//Assignment let num=99; if(num%2==0){ console.log("num is even number") } else{ console.log("num is odd number"); }
@ansafnisam24433 жыл бұрын
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....'
@danvathdarshan14263 ай бұрын
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
// 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) }
@babayaga61723 жыл бұрын
@9:18 AND Operator &&
@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
@ravi_sorathiya3 жыл бұрын
Perfect vscode them
@suchakbarik-08123 жыл бұрын
What is the name of this theme?
@sirojohnodilla9990 Жыл бұрын
let number = 8 if(number % 2 == 0){ console.log("number is even") } else{ console.log("number is odd") }
@oddshaharear36093 жыл бұрын
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"); }
@Team3-h9f Жыл бұрын
AND(&) operator
@Ankit-zi3yf3 жыл бұрын
Sir but when I try using else it says unexpected token
@teluskosupport1 Жыл бұрын
Sometimes, you leave out brackets around if statements: function round(n, upperBound, lowerBound) { if (n > upperBound) || (n < lowerBound) { // Not enough brackets here!
@venkatkvr4468 Жыл бұрын
let x = 10; let result = x % 2; if(result) console.log("x is odd"); else console.log("x is even");
@yellayiaruna61703 жыл бұрын
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?
@badrinadhyt64783 жыл бұрын
It's completely false case
@badrinadhyt64783 жыл бұрын
Both are equal num1==num2
@Bulldog012343 жыл бұрын
u should put num1 == num2 since both the numbers are the same
@tech_kollo2 жыл бұрын
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 Жыл бұрын
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');
@hunter982 Жыл бұрын
And opeartor
@manojpotdar23143 жыл бұрын
Hello sir
@ag_invento2 жыл бұрын
How to give functions in conditions
@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
@prasadbarhate91523 жыл бұрын
let num = 1; if(num%2==0) { console.log("num is even"); } else{ console.log("the num is odd"); }
@himanshuchoudhary43233 жыл бұрын
and operator
@padminicp25627 ай бұрын
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"); }
@padminicp25627 ай бұрын
Typo it's odd
@babyrhymes4u11 ай бұрын
let num1 = 6; if (num1 % 2 === 0) { console.log(num1 + " is even"); } else { console.log(num1 + " is odd"); }
@babayaga61723 жыл бұрын
// 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
@NareshShewakramani3 жыл бұрын
Semi colon (;) seems just a habit of java developer.
@ItsRam299 Жыл бұрын
x = 10; y = 2; if (x%y == 0){ console.log('even') } else{ console.log('odd') }
@dheerajkashyap76072 жыл бұрын
Answer of the Assignment : let num = 4 num%2==0?console.log("Even"):console.log("Odd")
@1conscience0dimension3 жыл бұрын
not a good practice but an unnecessary practice. you can put semi columns in python too :)
@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
@KaraSuraDraw13 жыл бұрын
Is using brackets even if you have 1 statement in the block best practice?
@teluskosupport1 Жыл бұрын
yes, best practice use dry principle and use brackets and semicolon .
@abdulrahmanmarudil29582 жыл бұрын
//Assignment let n = 30 if (n%2==0) { console.log(n,'is an even number.'); } else { console.log(n, 'is an odd number.'); }
@joshuaomotosho746310 ай бұрын
The if else is not clear sir, it's complex
@e.cjeyaruban47533 жыл бұрын
and operator(&&)
@teluskosupport1 Жыл бұрын
its a logical operator to add two condition and check both are true or not
@shaurya4ssvb8163 жыл бұрын
Elif
@akashshukla3783 жыл бұрын
AND
@naidutulasi8954 Жыл бұрын
And
@sivasaran43 жыл бұрын
let x=8 if(x%2==0) console.log("even") else console.log("odd") console.log("Happy coding") /* 💻🖥📱*/
@_parm_10 ай бұрын
9:23 &&
@mrrishiraj883 жыл бұрын
🙏👍
@tgturbo79582 жыл бұрын
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
@firefree31866 ай бұрын
default
@aryan40003 жыл бұрын
num = 19; if (num%2==0) { console.log("the number is even"); } else{ console.log("the number is odd"); }
@wellingtonshava-mhofu4208 Жыл бұрын
let a = number ("17"); if(a%2===0){ console.log("even"); } else{ console.log("odd"); {
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"); }
@folusoawolola81833 жыл бұрын
let num = 10; if (num%2===0) { console.log(String(num) +' '+'is an even number'); } else{ console.log(String(num) +' '+'is an odd number'); }
@LoU31073 жыл бұрын
Dude, improve your accent when talking in english
@brahmamnama87922 жыл бұрын
let num1=5 if((num1)%2==0) console.log('number is even'); else console.log('number is odd');
@GamingShitpost2 жыл бұрын
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 Жыл бұрын
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");
@souravmandal3868 Жыл бұрын
let num = 69; if (num & 1) console.log ("The number is odd!"); else console.log ("The number is even");
@AmeerMuawia-i4p3 ай бұрын
let n = 13; if(n%2 !=0 ) { console.log("The given value is odd") } else { console.log("The given value is even") }