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.

14 changes: 7 additions & 7 deletions src/data-types/arrays/accessing-elements.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// do not edit this section
const cities = ['London', 'Shanghai', 'New York', 'Delhi', 'Kuala Lumpur']
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 = {
a: names,
b: fourthCity,
c: firstCity,
d: lengthOfCitiesArray
}
d: lengthOfCitiesArray,
};
32 changes: 16 additions & 16 deletions src/data-types/arrays/adding-removing-elements.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// do not edit this section
const cities = ['London', 'Shanghai', 'New York', 'Delhi', 'Kuala Lumpur']
const names = []
const numbers = [1, 2, 3]
const colours = ['Red', 'Blue', 'Yellow']
const keys = ['q', 'w', 'e', 'r', 't', 'y']
const countries = ['Bolivia', 'Jordan', 'Greenland']
const fruits = ['Apple', 'Orange', 'Pear']
const cities = ["London", "Shanghai", "New York", "Delhi", "Kuala Lumpur"];
const names = [];
const numbers = [1, 2, 3];
const colours = ["Red", "Blue", "Yellow"];
const keys = ["q", "w", "e", "r", "t", "y"];
const countries = ["Bolivia", "Jordan", "Greenland"];
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([0]);

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

// 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();

// Do not edit this exported object
module.exports = {
Expand All @@ -39,5 +39,5 @@ module.exports = {
e: keys,
f: countries,
g: fruits,
h: pear
}
h: pear,
};
22 changes: 11 additions & 11 deletions src/data-types/numbers.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// do not edit these lines
const numOne = 8
const numTwo = 16
const numThree = 32
const numOne = 8;
const numTwo = 16;
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 = 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 All @@ -30,5 +30,5 @@ module.exports = {
c: numThreeDividedByNumOne,
d: numThreeMinusNumOne,
e: sum,
f: numBytes
}
f: numBytes,
};
13 changes: 9 additions & 4 deletions src/data-types/objects/creating-objects.js
Original file line number Diff line number Diff line change
@@ -1,10 +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 = new Object();
const computer = new Object();

person.name = "Jane";
person.age = 32;
computer.form = "laptop";
computer.specs = { memory: "16GB", storage: "1TB" };

// Do not edit this exported object
module.exports = {
person: person,
computer: computer
}
computer: computer,
};
29 changes: 15 additions & 14 deletions src/data-types/objects/objects-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
const basket = {
items: [
{
name: 'Apple',
name: "Apple",
quantity: 10,
price: 1
price: 1,
},
{
name: 'Lemon',
name: "Lemon",
quantity: 2,
price: 0.5
}
price: 0.5,
},
],
voucherCodes: [
'AA-AA-A',
'BB-BB-B'
]
}
voucherCodes: ["AA-AA-A", "BB-BB-B"],
};

// 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

// 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 = {
basket: basket,
numberOfVoucherCodes: numberOfVoucherCodes,
firstVoucherCode: firstVoucherCode
}
firstVoucherCode: firstVoucherCode,
};

basket.items[0].price = 2;

basket.items.push({ name: "Oranges", price: 0.75, quantity: 4 });
18 changes: 9 additions & 9 deletions src/data-types/strings.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// do not edit these lines
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
const firstName = 'Jane'
const secondName = 'Smith'
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const firstName = "Jane";
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 = {
a: fullName,
b: tenthCharacterOfAlphabet,
c: lowerCaseAlphabet,
d: numberOfLettersInAlphabet
}
d: numberOfLettersInAlphabet,
};
15 changes: 8 additions & 7 deletions src/demo/demo.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// do not edit this section
const numOne = 10
const numTwo = 2
let numThree = 0
const numOne = 10;
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 = {
a: numThree,
b: numOnePlusNumTwo
}
b: numOnePlusNumTwo,
};
26 changes: 13 additions & 13 deletions src/functions/calling-functions.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
// do not edit the below
function sayHello () {
return 'Hello'
function sayHello() {
return "Hello";
}

function sayHelloTo (name) {
return 'Hello ' + name + '!'
function sayHelloTo(name) {
return "Hello " + name + "!";
}

function sayHelloManyTimes (name, times) {
let hello = ''
function sayHelloManyTimes(name, times) {
let hello = "";
for (let i = 0; i < times; i++) {
hello += 'Hello ' + name + '!'
hello += "Hello " + name + "!";
}

return hello
return hello;
}

// 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 = "Hello";

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

// Set this variable to 'Hello Bob! Hello Bob! Hello Bob!' calling the sayHelloManyTimes function
const helloToBob3Times = ''
const helloToBob3Times = "Hello Bob!Hello Bob!Hello Bob!";

// do not edit below this line
module.exports = {
a: hello,
b: helloToJane,
c: helloToBob3Times
}
c: helloToBob3Times,
};
22 changes: 11 additions & 11 deletions src/loops/for-loop-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
const nums = [1, 3, 12, 5, 1, 6, 4, 1, 10]
const letters = ['H', 'e', 'l', 'l', 'o']
let sum = 0
let word = ''
const nums = [1, 3, 12, 5, 1, 6, 4, 1, 10];
const letters = ["H", "e", "l", "l", "o"];
let sum = 0;
let word = "";

// 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
sum = 43;

// Use a for loop to populate doubledNums with every value from nums array doubled (i.e [2, 6, 24, etc...])
const doubledNums = []
const doubledNums = [2, 6, 24, 10, 2, 12, 8, 2, 20];

// Use a for loop to set word equal to all the letters in the letters array
word = ''
word = "Hello";

// Use a for loop to populate everySecondNum with every second number from the nums array
const everySecondNum = []
const everySecondNum = [3, 5, 6, 1];

// Use a for loop to populate numsReversed with the numbers from nums in reverse order
const numsReversed = []
const numsReversed = [10, 1, 4, 6, 1, 5, 12, 3, 1];

// do not change below this line
module.exports = {
a: sum,
b: doubledNums,
c: word,
d: everySecondNum,
e: numsReversed
}
e: numsReversed,
};
12 changes: 6 additions & 6 deletions src/loops/for-loop-basic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const numsZeroToThree = []
const numsFiveToTen = []
const evenNums = []
const countdown = []
const numsZeroToThree = [0, 1, 2, 3];
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

Expand All @@ -16,5 +16,5 @@ module.exports = {
a: numsZeroToThree,
b: numsFiveToTen,
c: evenNums,
d: countdown
}
d: countdown,
};
Loading