Module 1: Conditionals 3,4, & 5 Flashcards
Write a function called “isLessThan”. Given 2 numbers, “isLessThan” returns whether num2 is less than num1.
function isLessThan(num1, num2) { if (num1 > num2) { return true; } else { return false; } }
Write a function called “isGreaterThan”. Given 2 numbers, “isGreaterThan” returns whether num2 is greater than num1.
function isGreaterThan(num1, num2) {
if (num2 > num1) {
return true;
} else {
return false;
}
}
Write a function called “isEqualTo”. Given 2 numbers, “isEqualTo” returns whether num2 is equal to num1.
function isEqualTo(num1, num2) {
if (num1 === num2) {
return true;
} else {
return false;
}
}
Write a function called “isEven”. Given a number, “isEven” returns whether it is even.
function isEven(num) {
if (num % 2 === 0){
return true;
} else {
return false;
}
}
Write a function called “isOdd”. Given a number, “isOdd” returns whether the given number is odd.
function isOdd(num) {
if (num % 2 !== 0) {
return true;
} else {
return false;
}
}
Write a function called “isSameLength”.
Given two words, “isSameLength” returns whether the given words have the same length.
function isSameLength(word1, word2) {
if (word1.length === word2.length) {
return true;
} else {
return false;
}
}
Write a function called “areBothOdd”.
Given 2 numbers, “areBothOdd” returns whether or not both of the given numbers are odd.
function areBothOdd(num1, num2) {
if (num1 % 2 !==0 && num2 % 2 !==0) {
return true;
} else {
return false;
}
}
Write a function called “isEitherEven”.
Given two numbers, “isEitherEven” returns whether or not either one of the given numbers is even.
function isEitherEven(num1, num2) {
if (num1 % 2 === 0 || num2 % 2 === 0) {
return true;
} else {
return false;
}
}
Write a function called “isOddLength”.
Given a word, “isOddLength” returns whether the length of the given word is odd.
**function isOddLength(word) { // your code here /\* START SOLUTION \*/ if (word.length % 2 !== 0) { return true; } else { return false; } }**
Write a function called “isEvenLength”.
Given a word, “isEvenLength” returns whether the length of the word is even.
function isEvenLength(word) {
if (word.length % 2 === 0) {
return true;
} else {
return false;
}
}
Write a function called “isEvenAndGreaterThanTen”.
Given a number, “isEvenAndGreaterThanTen” returns whether it is both even and greater than 10.
function isEvenAndGreaterThanTen(num) {
if (num % 2 === 0 && num > 10) {
return true;
} else {
return false;
}
}