Skip to content

Instantly share code, notes, and snippets.

@jfrites
Created January 3, 2020 00:23
Show Gist options
  • Save jfrites/b1ea1f861fd12fb809e158bc08f5215b to your computer and use it in GitHub Desktop.
Save jfrites/b1ea1f861fd12fb809e158bc08f5215b to your computer and use it in GitHub Desktop.
If Else Examples
let name = 'David';
// let name = 'Nimit';
// let name = 'Someone else';
let found;
// YOUR CODE BELOW
name = "Nimit"
if (name === "David" || name === "Nimit") found = true;
else found= false;
console.log(found)
//perfect
let word = 'carrots';
// let word = 'pacific';
// let word = 'perfecto';
// let word = 'perfect';
let lastWord;
// YOUR CODE BELOW
word ='perfection'
if (word.includes('p') && word.length >= 7) lastWord = word.toUpperCase();
else lastWord = word
console.log(lastWord);
//truth teller
let boolean1 = false,
boolean2 = false;
// let boolean1 = true, boolean2 = false;
// let boolean1 = false, boolean2 = true;
// let boolean1 = false, boolean2 = false;
let result;
// YOUR CODE BELOW
// check if both are equal to true
if (boolean1 === true && boolean2 === true) {
result = 'both';
//checks if one is equal to true
}else if (boolean1 === true || boolean2 === true){
result = 'one';
//checks all else
}else {
result = 'none';
}
//logs to console
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment