JavaScript Fundamentals: Conditionals

Day 5 of #100DaysOfCode

Console Log

let a = 22; 
a = a + 10;
console.log(a); // 32;

Conditionals

if(1 === 1) {
console.log( "Yes, it's true!" );
}
function isEqual(a, b) {
return(a===b);
}
console.log( 1 !== 2 ); // true
console.log( 2 !== 2 ); // false
console.log( 3 !== 2 ); // true
function isNotEqual(a, b) {     
if(a !== b){
return true;
}
}
if(isRaining === true) {
stayIndoors();
}
else {
// isRaining is not true
goOutside();
}
function greater(first, last) {
if (first > last){
return first;
}
if (last > first) {
return last;
}
}
console.log(1 > 3); // false 
console.log(3 > 1); // true
console.log(3 < 1); // false
console.log(1 < 3); // true
function greaterThanOrEqualTo(a, b) {
if(a > b) {
return true;
}
if(a === b) {
return true;
}
}

// or
// Both will accomplish the same functionality.

function isEqual(a,b) {
if(a === b) {
return true;
}
return false;
}
if(firstCondition) {
// firstCondition is true
}
else if (otherCondition) {
// firstCondition is not true and otherCondition is true
}
else {
// neither condition is true
}
const a = true; 
const b = true;
if(a) {
// this will run
}
else if (b) {
// this will not run!
}
else {
// this will definitely not run.
}

Conclusion

--

--

Student | Content Creator | Explorer and Learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store