Comparison Operators & If Else - Beau teaches JavaScript
HTML-код
- Опубликовано: 9 фев 2017
- Learn about comparison operators. Also, if else statements!
Code
🔗 codepen.io/beau...
Other resources on topic:
🔗 developer.mozi...
Beau Carnes on Twitter: / carnesbeau
⭐JavaScript Playlists⭐
▶JavaScript Basics: • JavaScript Basics Course
▶ES6: • ES6 - Beau teaches Jav...
▶Design Patterns: • Design Patterns - Beau...
▶Data Structures and Algorithms: • Data Structures and Al...
▶Clean Code: • Clean Code - Beau teac...
-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.
Join our community at freecodecamp.com
Follow us on twitter: / freecodecamp
Like us on Facebook: / freecodecamp
Follow Quincy on Quora: www.quora.com/...
You mentioned whenever we have an expression with an assignment to a number, inside the if condition, it is always going to evaluate to TRUE. but that is only if the assignment is for a non-zero number
for ex:
if (age = 1) will be, true
if (age = 0) will be, false
if (age = 0.0) will be, false
Good point (tho' the point is that it means something different from asking if it's equal...)
With the if...else statements failing on baby, another way other than swapping could be:
if else (age > 2 && age < 18)
console.log("You are a child");
The alligator always eats the bigger number... it's greedy that way. (how I learned < and >)
that's so cute and handy
Makes perfect sense, thanks.
Please slowwwwww down. Love what you are doing.
this so similar to python!
how to solve a multiple if statement with in a single function
example program is
function testLessThan(val) {
if (val < ) {
return "Under 25";
}
else if (val < ) {
return "Under 55";
}
return "55 or Over";
}
// Change this value to test
testLessThan(10);
Thank You @t !
thank u
What about === and !== ?
Albin Metthey I have a "=== vs ==" video coming out soon but it may have been good to include those in this video.
Mr. Carnes explicitly says in the very end of the video that this information is covered in later videos. I think the aim of the course is to give the information by small comprehensible bits to get the basic idea of the concepts.
Thx!!!!!
Which software is it ?
Codepen