Module 1: Conditionals 3,4, & 5 Flashcards

1
Q

Write a function called “isLessThan”. Given 2 numbers, “isLessThan” returns whether num2 is less than num1.

A

function isLessThan(num1, num2) { if (num1 > num2) { return true; } else { return false; } }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Write a function called “isGreaterThan”. Given 2 numbers, “isGreaterThan” returns whether num2 is greater than num1.

A

function isGreaterThan(num1, num2) {
if (num2 > num1) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a function called “isEqualTo”. Given 2 numbers, “isEqualTo” returns whether num2 is equal to num1.

A

function isEqualTo(num1, num2) {
if (num1 === num2) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write a function called “isEven”. Given a number, “isEven” returns whether it is even.

A

function isEven(num) {
if (num % 2 === 0){
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write a function called “isOdd”. Given a number, “isOdd” returns whether the given number is odd.

A

function isOdd(num) {
if (num % 2 !== 0) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write a function called “isSameLength”.

Given two words, “isSameLength” returns whether the given words have the same length.

A

function isSameLength(word1, word2) {
if (word1.length === word2.length) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write a function called “areBothOdd”.

Given 2 numbers, “areBothOdd” returns whether or not both of the given numbers are odd.

A

function areBothOdd(num1, num2) {
if (num1 % 2 !==0 && num2 % 2 !==0) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Write a function called “isEitherEven”.

Given two numbers, “isEitherEven” returns whether or not either one of the given numbers is even.

A

function isEitherEven(num1, num2) {
if (num1 % 2 === 0 || num2 % 2 === 0) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write a function called “isOddLength”.

Given a word, “isOddLength” returns whether the length of the given word is odd.

A
**function isOddLength(word) {
 // your code here
 /\* START SOLUTION \*/
 if (word.length % 2 !== 0) {
 return true;
 } else {
 return false;
 }
 }**
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write a function called “isEvenLength”.

Given a word, “isEvenLength” returns whether the length of the word is even.

A

function isEvenLength(word) {
if (word.length % 2 === 0) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write a function called “isEvenAndGreaterThanTen”.

Given a number, “isEvenAndGreaterThanTen” returns whether it is both even and greater than 10.

A

function isEvenAndGreaterThanTen(num) {
if (num % 2 === 0 && num > 10) {
return true;
} else {
return false;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly