Skip to content

Commit

Permalink
core and extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Chen Jensen committed Feb 15, 2024
1 parent a88174f commit a8a9565
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/boolean-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ let didPass
// "Well done, you passed!" if didPass is true, or "Sorry, try again!" if didPass
// is false
let answer
if (didPass) {
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
22 changes: 20 additions & 2 deletions src/multiple-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ const NUM = 9 // eslint-disable-line no-unused-vars
// AND is less than or equal to the UPPER variable
let answerOne

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

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

// 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
if (STR === 'Hello' || STR === 'Goodbye') {
answerTwo = true
} else {
answerTwo = false
}

// Task 3
const AGE = 0
const AGE = 1

// 3. Use conditional statements to set the answerThree variable below to a
// string value based on what the AGE variable is set to.
Expand All @@ -34,6 +43,15 @@ const AGE = 0
// 13-19 | Teenager
// 20+ | Adult
let answerThree
if (AGE === 0) {
answerThree = 'Baby'
} else if (AGE > 0 && AGE < 5) {
answerThree = 'Toddler'
} else if (AGE > 4 && AGE < 13) {
answerThree = 'Teenager'
} else if (AGE > 19) {
answerThree = 'Adult'
}

// Run the test after changing the AGE value to verify you've successfully
// accounted for each age range
Expand Down
16 changes: 16 additions & 0 deletions src/numeric-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,32 @@ 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
if (ARRAY_ONE.length === 0) {
answerOne = true
} else {
answerOne = false
}

// 2. Use conditional statements to set answerTwo to false if ARRAY_TWO is not empty
// or true if it is empty
let answerTwo
if (ARRAY_TWO.length === 0) {
answerTwo = true
} else {
answerTwo = false
}

// 3. Use conditional statements to set answerThree to true if NUM_ONE is more than NUM_TWO
let answerThree
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
if (ARRAY_TWO.includes(NUM_ONE) || ARRAY_TWO.includes(NUM_TWO)) {
answerFour = true
}

// Don't edit the code below this line
module.exports = {
Expand Down
44 changes: 44 additions & 0 deletions src/string-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,71 @@
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[0].toLowerCase() === STR_FIVE[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
if (STR_SIX[0].toLowerCase() === STR_SIX[STR_SIX.length - 1].toLowerCase()) {
answerFive = true
console.log(STR_SIX[0], STR_SIX[STR_SIX.length - 1])
} else {
answerFive = false
}

// 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 === 1) {
answerSix = STR_SEVEN[parseInt(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
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 @@ -56,6 +83,23 @@ let answerSeven
const MONTH = 'January'

let answerEight
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'
} else if (
MONTH === 'December' ||
MONTH === 'January' ||
MONTH === 'February'
) {
answerEight = 'Winter'
}

module.exports = {
answerOne,
Expand Down

0 comments on commit a8a9565

Please sign in to comment.