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
4 changes: 2 additions & 2 deletions spec/data-types/arrays/accessing-elements.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ describe("Arrays accessing:", () => {
})

it("fourthCity is Delhi", () => {
expect(answers.b).toEqual("Delhi")
expect(answers.b).toEqual(answers._c.find(city => city.location === "Delhi"))
})

it("firstCity is London", () => {
expect(answers.c).toEqual("London")
expect(answers.c).toEqual(answers._c.find(city => city.location === "London"))
})

it("lengthOfCitiesArray is 5", () => {
Expand Down
8 changes: 8 additions & 0 deletions src/_support/location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Location {
constructor(location) {
this.location = location;
this.randNumber = Math.floor(Math.random() * 1000);
}
}

module.exports = Location
9 changes: 6 additions & 3 deletions src/data-types/arrays/accessing-elements.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
const Location = require('../../_support/location')

// do not edit this section
const cities = ['London', 'Shanghai', 'New York', 'Delhi', 'Kuala Lumpur']
const cities = [new Location('London'), new Location('Shanghai'), new Location('New York'), new Location('Delhi'), new Location('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

// 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 = new Location('London')

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

// Do not edit this exported object
module.exports = {
_c: cities,
a: names,
b: fourthCity,
c: firstCity,
Expand Down