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

Iris Flystam #292

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
14 changes: 7 additions & 7 deletions src/advanced/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ const nums = [1, 10, 3, 9, 4, 8, 5, 7, 6, 2, -5, -2, -4, -9] // eslint-disable-l
// 1. Use a for loop to set the variable hasTen to true if the array contains the value 10
// note: use a break statement to exit the loop early if the value is found
// to prove you have done this, set the variable indexOfTen to the iteration index when you find 10
let hasTen = false
let indexOfTen = -1
const hasTen = false
const indexOfTen = -1

// 2. Use a for loop to count how many numbers in the array are divisible by 3
let divisibleByThreeCount = 0
const divisibleByThreeCount = 0

// 3. use a for loop to find the average of the numbers in the array
let average = 0
const average = 0

// 4. use a for loop to find the largest number in the array
let largest = 0
const largest = 0

// 5. use a for loop to find the smallest number in the array
let smallest = 100000
const smallest = 100000

// 6. find the median of the numbers in the array
let median = 0
const median = 0

module.exports = {
hasTen,
Expand Down
15 changes: 15 additions & 0 deletions src/for-loop-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,32 @@ let word = '' // eslint-disable-line prefer-const
// TODO: Add code below this line to make the tests pass

// 1. Use a for loop to set the sum variable to the sum of all the values in nums
for (let i = 0; i < nums.length; i++) {
sum += nums[i]
}

// 2. Use a for loop to populate doubledNums with every value from nums array doubled (i.e [2, 6, 24, etc...])
const doubledNums = []
for (let i = 0; i < nums.length; i++) {
doubledNums.push(nums[i] * 2)
}

// 3. Use a for loop to set word variable equal to all the letters in the letters array combined as a single string
for (let i = 0; i < letters.length; i++) {
word += letters[i]
}

// 4. Use a for loop to populate everySecondNum with every second number from the nums array
const everySecondNum = []
for (let i = 1; i < nums.length; i = i + 2) {
everySecondNum.push(nums[i])
}

// 5. Use a for loop to populate numsReversed with the numbers from nums in reverse order
const numsReversed = []
for (let i = nums.length - 1; i > -1; i--) {
numsReversed.push(nums[i])
}

// do not change below this line
module.exports = {
Expand Down
12 changes: 12 additions & 0 deletions src/for-loop-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ const evenNums = []
const countdown = []

// TODO: 1. Write a for loop that adds the numbers 0 to 3 to the numsZeroToThree array
for (let i = 0; i < 4; i++) {
numsZeroToThree.push(i)
}

// TODO: 2. Write a for loop that adds the numbers 5 to 10 to the numsFiveToTen array
for (let i = 5; i < 11; i++) {
numsFiveToTen.push(i)
}

// TODO: 3. Write a for loop that adds all the even numbers between 0 and 6 (0, 2, 4, 6) to evenNums
for (let i = 0; i < 7; i = i + 2) {
evenNums.push(i)
}

// TODO: 4. Write a for loop that adds the numbers 3 to 0 (in that order) to the countdown array
for (let i = 3; i > -1; i--) {
countdown.push(i)
}

// do not change below this line
module.exports = {
Expand Down
Loading