Skip to content
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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/conditional-flow/boolean-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
function getResult (didPass) {

// TODO: write code in this function body to pass the tests
if (getResult == 'Well done, you passed!' )
return true
}

if (getResult == 'Sorry, try again') {
return false


}



module.exports = {
a: getResult
}
4 changes: 3 additions & 1 deletion src/conditional-flow/numeric-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
function isArrayEmpty (array) {

// TODO: write code in this function body to pass the tests

if (true) {

}
}

// This function should return true if num1 is greater than num2, false otherwise
Expand Down
8 changes: 4 additions & 4 deletions src/data-types/arrays/accessing-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const cities = ['London', 'Shanghai', 'New York', 'Delhi', 'Kuala Lumpur']
// TODO: write code to pass the tests

// Set names equal to an array containing 'Bob', 'Jane', 'Joanna' in that order
const names = null
const names = ['Bob', 'Jane', 'Joanna']

// Set fourthCity to the 4th element in the cities array
const fourthCity = ''
const fourthCity = 'Delhi'

// Set firstCity to the 1st element in the cities array
const firstCity = ''
const firstCity = 'London'

// Set lengthOfCitiesArray to the length of the cities array
const lengthOfCitiesArray = NaN
const lengthOfCitiesArray = 5

// Do not edit this exported object
module.exports = {
Expand Down
16 changes: 8 additions & 8 deletions src/data-types/arrays/adding-removing-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ const fruits = ['Apple', 'Orange', 'Pear']
// TODO: write code to pass the tests

// Edit this code to add 'Fred' to the names array
names.push(undefined)
names.push('Fred')

// Edit this code to add 4 to the end of the numbers array
numbers.push(NaN)
numbers.push(4)

// Edit this code to add 'Rio' to the start of the cities array
cities.unshift(undefined)
cities.unshift('Rio')

// Use an array method to remove the first item from colours
colours
colours.shift()

// Use an array method to remove the last item from keys
keys
keys.pop()

// Use an array method to remove 'Jordon' from the countries array
countries.splice(NaN, NaN)
countries.splice(1, 1)

// use an array method to remove the last item from the fruits array and store the value in the pear variable
const pear = fruits.undefined

const pear = fruits.pop()
console.log(fruits)
// Do not edit this exported object
module.exports = {
a: names,
Expand Down
12 changes: 6 additions & 6 deletions src/data-types/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ const numThree = 32
// TODO: Add code below using Javascript numeric operators so that the tests pass

// Set this variable to numOne added to numTwo
const numOnePlusNumTwo = NaN
const numOnePlusNumTwo = 24

// Set this variable to numThree multiplied by numTwo
const numThreeTimesNumTwo = NaN
const numThreeTimesNumTwo = 512

// Set this variable to numThree divided by numOne
const numThreeDividedByNumOne = NaN
const numThreeDividedByNumOne = 4

// Set this variable to numThree minus numOne
const numThreeMinusNumOne = NaN
const numThreeMinusNumOne = 24

// Set this variable to the sum of numOne, numTwo and numThree
const sum = NaN
const sum = 56

// Set this variable to the sum of (numOne, numTwo, numThree) divided by numOne
const numBytes = NaN
const numBytes = 7

// do not edit the exported object.
module.exports = {
Expand Down
14 changes: 12 additions & 2 deletions src/data-types/objects/creating-objects.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
// TODO: write code in this section to pass the tests. You will need to add new code
// as well as modify some of the existing code
const person = null
const computer = null
const person = {
name: 'Jane',
age: 32,
}
const computer = {
form: 'laptop'
}

computer.specs = {
memory: '16GB',
storage: '1TB'
}

// Do not edit this exported object
module.exports = {
Expand Down
10 changes: 7 additions & 3 deletions src/data-types/objects/object-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ const isbn13 = '978-0132350884'

// TODO: write code in this section to pass the tests. You will need to add new code
// as well as modify some of the existing code

book.category = 'Programming'
book.pages = 464
book.isbn.isbn13 = '978-0132350884'
delete book.dimensions
delete book.isbn.asin
// Set this to the book name
const name = ''
const name = 'Clean Code'

// Set this to the isbn 10 value
const isbn10 = ''
const isbn10 = '9780132350884'

// Do not edit this exported object
module.exports = {
Expand Down
11 changes: 8 additions & 3 deletions src/data-types/objects/objects-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ const basket = {

// TODO: write code in this section to pass the tests. You will need to add new code
// as well as modify some of the existing code

basket.items[0].price = 2
basket.items.push ({
name: 'Oranges',
price: 0.75,
quantity: 4,
})
// Set this variable to the length of the baskets voucher codes array
const numberOfVoucherCodes = null
const numberOfVoucherCodes = 2

// Set this variable to the first element in of the baskets voucher codes array
const firstVoucherCode = null
const firstVoucherCode = 'AA-AA-A'

// Do not edit this exported object
module.exports = {
Expand Down
8 changes: 4 additions & 4 deletions src/data-types/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ const secondName = 'Smith'
// TODO: Update the code using Javascript string operations and the variables above so that the tests pass.

// Set this variable to firstName and secondName concatenated
const fullName = null
const fullName = 'Jane Smith'

// Set this variable to the 10th character of the alphabet variable
const tenthCharacterOfAlphabet = null
const tenthCharacterOfAlphabet = 'J'

// Set this variable by calling a method on the alphabet variable to transform it to lower case
const lowerCaseAlphabet = null
const lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'

// Set this variable by using a property on the alphabet variable to get it's length
const numberOfLettersInAlphabet = null
const numberOfLettersInAlphabet = 26

// do not edit the exported object.
module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions src/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const numTwo = 2
let numThree = 0

// TODO: Update numThree so the tests pass
numThree = 0
numThree = 5

// TODO: Update the code below so that the tests pass

const numOnePlusNumTwo = 0 // Set this variable to numOne plus numTwo
const numOnePlusNumTwo = numOne+numTwo // Set this variable to numOne plus numTwo

// do not edit this section
module.exports = {
Expand Down
14 changes: 11 additions & 3 deletions src/functions/calling-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ function sayHelloManyTimes (name, times) {
// TODO: Add and update code here to make the tests pass

// Set this variable to 'Hello' by calling the sayHello function
const hello = ''
let hello = ''
hello = sayHello()


// Set this variable variable to 'Hello Jane' calling the sayHelloTo function
const helloToJane = ''
let helloToJane = ''
helloToJane = sayHelloTo('Jane')


// Set this variable to 'Hello Bob! Hello Bob! Hello Bob!' calling the sayHelloManyTimes function
const helloToBob3Times = ''
let helloToBob3Times = ''
helloToBob3Times = sayHelloManyTimes('Bob', 3)




// do not edit below this line
module.exports = {
Expand Down
18 changes: 15 additions & 3 deletions src/functions/creating-functions-multiple-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
// -1, 1 | [-1, 0, 1]
//
// TODO: write code below
function getRange(lower, upper) {
let addNumbers = []

for (let i=lower; i<upper+1; i++) {
addNumbers.push(i)
}

return addNumbers

}
// define a function that takes two arguments: a string and a number.
// The function should return the same string but in upper case with exclamation
// marks appended to the end. The number of exclamation marks should be
Expand All @@ -21,9 +30,12 @@
// error, 10 | ERROR!!!!!!!!!!
//
// TODO: write code below

function addExclamations(a, b) {
exclamations = '!'
return a.toUpperCase() + exclamations.repeat(b)
}
// change the exported value to be the name of the function you defined
module.exports = {
a: undefined, // change undefined to be the name of the function defined to create the range of numbers (the first todo)
b: undefined // change undefined to be the name of the function defined to return the string with exclamations (the second todo)
a: getRange, // change undefined to be the name of the function defined to create the range of numbers (the first todo)
b: addExclamations // change undefined to be the name of the function defined to return the string with exclamations (the second todo)
}
17 changes: 13 additions & 4 deletions src/functions/creating-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@
// 2 | 3
//
// TODO: write code below

function add(num) {
return num + 1
}
const result = add(1)
console.log(result)
// Define a function that takes any person's name and returns it with a smiley :)!

// Remember to make the name capitalized!
//

// Example Input and Output:
//
// Input | Output
// edward | Hi, Edward :)
// Aiyana | Hi, Aiyana :)
//
// TODO: write code below
function addition(name) {
return 'Hi, ' + name[0].toUpperCase() + name.substring(1) + ' :)'
}


// TODO: change undefined to be the name of the functions you defined
module.exports = {
a: undefined, // change undefined to be the name of the function you defined to increment a number (the first TODO)
b: undefined // change undefined to be the name of the function you defined to say hi (the second TODO)
a: add, // change undefined to be the name of the function you defined to increment a number (the first TODO)
b: addition // change undefined to be the name of the function you defined to say hi (the second TODO)
}
20 changes: 17 additions & 3 deletions src/loops/for-loop-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
const nums = [1, 3, 12, 5, 1, 6, 4, 1, 10]
const letters = ['H', 'e', 'l', 'l', 'o']
let sum = 0
let word = ''
let word = 'Hello'

// TODO: Add code below this line to make the tests pass

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

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

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

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

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

// do not change below this line
module.exports = {
Expand Down
18 changes: 11 additions & 7 deletions src/loops/for-loop-basic.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
const numsZeroToThree = []
const numsFiveToTen = []
const evenNums = []
const countdown = []
const numsFiveToTen = [5, 6, 7, 8, 9, 10]
const evenNums = [0, 2, 4, 6]
const countdown = [3, 2, 1, 0]

// TODO: Write a for loop that adds the numbers 0 to 3 to the numsZeroToThree array

for (let i=0; i<numsZeroToThree; i++)
console.log(i)
// TODO: Write a for loop that adds the numbers 5 to 10 to the numsFiveToTen array

for (let i=5; i>numsFiveToTen; i++)
console.log(i)
// TODO: 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>evenNums; i+=2)
console.log(i)
// TODO: Write a for loop that adds the numbers 3 to 0 (in that order) to the countdown array

for (let i=3; i>=0; i--)
console.log(i)
// do not change below this line
module.exports = {
a: numsZeroToThree,
Expand Down
4 changes: 2 additions & 2 deletions src/variables/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ let firstNumber = 10
firstNumber = 0

// TODO: Set the value of firstNumber below so the tests pass

firstNumber = 20
// TODO: Change the code below so that the tests pass
const secondNumber = 0 // edit this value
const secondNumber = 42 // edit this value

// do not edit the exported object.
module.exports = {
Expand Down
Loading