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
Empty file added boolean-conditions.js
Empty file.
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.

2 changes: 1 addition & 1 deletion src/conditional-flow/boolean-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// "Well done, you passed!" if the value is true, or "Sorry, try again"
// if the value is false.
function getResult (didPass) {

console.log("interaction",)
// TODO: write code in this function body to pass the tests

}
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 = cities(3)

// Set firstCity to the 1st element in the cities array
const firstCity = ''
const firstCity = cities(0)

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

// Do not edit this exported object
module.exports = {
Expand Down
15 changes: 8 additions & 7 deletions src/data-types/arrays/adding-removing-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,27 @@ 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()

fruits.splice(2, 1)
// Do not edit this exported object
module.exports = {
a: names,
Expand Down
14 changes: 6 additions & 8 deletions src/data-types/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@ 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 = numOne + numTwo

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

const numThreeTimesNumTwo = numThree * numTwo
// Set this variable to numThree divided by numOne
const numThreeDividedByNumOne = NaN

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

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

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

// do not edit the exported object.
module.exports = {
Expand Down
12 changes: 10 additions & 2 deletions src/data-types/objects/creating-objects.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
// 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: 'mike',
age: 75
}
const computer = {
form: 'laptop',
specs: {
memory: '1gB',
}
}

// Do not edit this exported object
module.exports = {
Expand Down
10 changes: 5 additions & 5 deletions src/data-types/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ 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 = alphabet[9]

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

// Set this variable by using a property on the alphabet variable to get it's length
const numberOfLettersInAlphabet = null
const lowerCaseAlphabet = alphabet.toLowerCase()

// Set this variable by using a property on the alphabet variable to get it's length
const numberOfLettersInAlphabet = alphabet.length
// do not edit the exported object.
module.exports = {
a: fullName,
Expand Down
6 changes: 3 additions & 3 deletions src/functions/calling-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ 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 = ''
const hello = sayHello()

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

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

// do not edit below this line
module.exports = {
Expand Down
12 changes: 8 additions & 4 deletions src/functions/creating-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// 2 | 3
//
// TODO: write code below

function incrementsNumber(num){
return num + 1
// Define a function that takes any person's name and returns it with a smiley :)!
// Remember to make the name capitalized!
//
Expand All @@ -18,9 +19,12 @@
// Aiyana | Hi, Aiyana :)
//
// TODO: write code below
function Smiley(name){

return "Hi, " + name.charAt(0).toUpperCase() + name.slice(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: incrementsNumber, // change undefined to be the name of the function you defined to increment a number (the first TODO)
b: Smiley // change undefined to be the name of the function you defined to say hi (the second TODO)
3 changes: 2 additions & 1 deletion src/loops/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const nums3 = []
for (let i = 1; i < 6; i++) {
nums.push(i)
}

console.log("i<5")
e
// TODO: Write a for loop to add the all but the last number of nums to the nums2 array
for (let i = 0; i < nums2.length - 1; i++) {
nums3.push(nums2[i])
Expand Down
15 changes: 11 additions & 4 deletions src/loops/for-loop-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@ let word = ''

// 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 = []

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 = []

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 (i = nums.length -1; i >= 0; i--){
numsReversed.push(nums[i]);
// do not change below this line
module.exports = {
a: sum,
Expand Down
12 changes: 8 additions & 4 deletions src/loops/for-loop-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ const evenNums = []
const countdown = []

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

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

for (let i = 5; i <= 10; i++){
numsFiveToTen.push(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 <= 6; i++){
if(i % 2 === 0) evenNums.push(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--){
countdown.push(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
5 changes: 3 additions & 2 deletions src/variables/declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//
//
// TODO: Declare the variables firstName and age so that the tests pass

let firstName = "Jane"
const age = 35
// do not edit below this line
let firstNameExport = ''
let firstNameExport = '1'
try { firstNameExport = firstName } catch (e) {}

let ageExport = 0
Expand Down