Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuva Aarseth #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/boolean-conditions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
// Initialise the didPass variable with a boolean value
let didPass
const didPass = true

// 1. Create a conditional statement that changes the answer variable to the string
// "Well done, you passed!" if didPass is true, or "Sorry, try again!" if didPass
// is false

let answer
if (didPass === true) {
answer = 'Well done, you passed!'
}

/* else {
answer = 'Sorry, try again!'
} */

// 2. When you're done and the test passes, changing didPass to the opposite boolean
// and run the test again to make sure it still passes
Expand Down
47 changes: 44 additions & 3 deletions src/multiple-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ const NUM = 9 // eslint-disable-line no-unused-vars
// 1. Use conditional statements to set the value of the answerOne variable
// to be true if the NUM variable is more than or equal to the LOWER variable
// AND is less than or equal to the UPPER variable
let answerOne
let answerOne = false

if (NUM >= LOWER && NUM <= UPPER) {
answerOne = true
}

// Task 2
const STR = null
const STR = 'Hello'

// 2. Use conditional statements to set the answerTwo variable below to true
// if the STR variable is 'Hello' or 'Goodbye'
// Set answerTwo to false if it's neither of those
// Run the test after setting STR to 'Hello', then 'Goodbye', then any other value you like
// to verify your code is correct
let answerTwo
let answerTwo = false

if (STR === 'Hello' || STR === 'Goodbye') {
answerTwo = true
}
// Task 3
const AGE = 0

Expand All @@ -35,6 +42,40 @@ const AGE = 0
// 20+ | Adult
let answerThree

switch (AGE) {
case 0:
answerThree = 'Baby'
break
case 1:
case 2:
case 3:
case 4:
answerThree = 'Toddler'
break
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
answerThree = 'Child'
break
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
answerThree = 'Teenager'
break
default:
answerThree = 'Adult'
break
}

// Run the test after changing the AGE value to verify you've successfully
// accounted for each age range

Expand Down
24 changes: 20 additions & 4 deletions src/numeric-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,33 @@ const ARRAY_TWO = ['Hello', 'Conditions', NUM_ONE] // eslint-disable-line no-unu

// 1. Use conditional statements to set answerOne to false if ARRAY_ONE is not empty
// or true if it is empty
let answerOne
let answerOne = false

if (ARRAY_ONE.length === 0) {
answerOne = true
}

// 2. Use conditional statements to set answerTwo to false if ARRAY_TWO is not empty
// or true if it is empty
let answerTwo
let answerTwo = false

if (ARRAY_TWO.length === 0) {
answerTwo = true
}

// 3. Use conditional statements to set answerThree to true if NUM_ONE is more than NUM_TWO
let answerThree
let answerThree = false

if (NUM_ONE > NUM_TWO) {
answerThree = true
}

// 4. Use conditional statements to set answerFour to true if NUM_ONE or NUM_TWO are included in ARRAY_TWO
let answerFour
let answerFour = false

if (ARRAY_TWO.includes(NUM_ONE || NUM_TWO)) {
answerFour = true
}

// Don't edit the code below this line
module.exports = {
Expand Down
53 changes: 52 additions & 1 deletion src/string-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,80 @@ const STR_ONE = 'Hello' // eslint-disable-line no-unused-vars

let answerOne

if (STR_ONE === 'Hello') {
answerOne = true
}

// 2. Use conditional statements to set answerTwo to true if STR_TWO is not 'Hello'
const STR_TWO = 'Goodbye' // eslint-disable-line no-unused-vars

let answerTwo

if (STR_TWO !== 'Hello') {
answerTwo = true
}

// 3. Use conditional statements to set answerThree to true if STR_THREE is
// longer than STR_FOUR
const STR_THREE = 'Hello' // eslint-disable-line no-unused-vars
const STR_FOUR = 'Good' // eslint-disable-line no-unused-vars

let answerThree

if (STR_THREE.length > STR_FOUR.length) {
answerThree = true
}

// 4. Use conditional statements to set answerFour to true
// if STR_FIVE starts and ends with the same character, regardless of case

const STR_FIVE = 'Alexandra' // eslint-disable-line no-unused-vars

let answerFour

if (
STR_FIVE.charAt(0).toLowerCase() ===
STR_FIVE.charAt(STR_FIVE.length - 1).toLowerCase()
) {
answerFour = true
}

// 5. Use conditional statements to set answerFive to true
// if STR_SIX starts and ends with the same character, regardless of case

const STR_SIX = 'Joanna' // eslint-disable-line no-unused-vars

let answerFive
let answerFive = false

if (
STR_SIX.charAt(0).toLowerCase() ===
STR_SIX.charAt(STR_SIX.length - 1).toLowerCase()
) {
answerFive = true
}

// 6. Use conditional statements to set answerSix to the middle character of STR_SEVEN
// if STR_SEVEN has an odd number of characters
const STR_SEVEN = 'Kayla' // eslint-disable-line no-unused-vars

let answerSix

if (STR_SEVEN.length % 2 !== 0) {
answerSix = STR_SEVEN.charAt(STR_SEVEN.length / 2)
}

// 7. Use conditional statements to set answerSeven to the middle two characters of
// STR_EIGHT if STR_EIGHT has an even number of characters
const STR_EIGHT = 'Alex' // eslint-disable-line no-unused-vars

let answerSeven
console.log(STR_EIGHT.slice(STR_EIGHT.length / 2 - 1, STR_EIGHT.length / 2 + 1))
if (STR_EIGHT.length % 2 === 0) {
answerSeven = STR_EIGHT.slice(
STR_EIGHT.length / 2 - 1,
STR_EIGHT.length / 2 + 1
)
}

// 8. Set answerEight to the appropriate season based on what MONTH is set to
//
Expand All @@ -57,6 +94,20 @@ const MONTH = 'January'

let answerEight

if (MONTH === 'December' || MONTH === 'January' || MONTH === 'February') {
answerEight = 'Winter'
} else if (MONTH === 'March' || MONTH === 'April' || MONTH === 'May') {
answerEight = 'Spring'
} else if (MONTH === 'June' || MONTH === 'July' || MONTH === 'August') {
answerEight = 'Summer'
} else if (
MONTH === 'September' ||
MONTH === 'October' ||
MONTH === 'November'
) {
answerEight = 'Autumn'
}

module.exports = {
answerOne,
answerTwo,
Expand Down
Loading