From 9371b9a488838b010264625e4e2db19c43851b0d Mon Sep 17 00:00:00 2001 From: TMajlu Date: Tue, 1 Oct 2024 13:08:10 +0200 Subject: [PATCH 1/2] Thomas Nielsen --- .idea/.gitignore | 3 +++ .idea/vcs.xml | 4 ++++ src/core.js | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..d843f34 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/core.js b/src/core.js index 6380dd5..4db6f74 100644 --- a/src/core.js +++ b/src/core.js @@ -2,36 +2,50 @@ const person = { age: 32, size: 'Small' } // 1. Give the person object a name property with the value Matt +person.name='Matt' + // 2. Remove the size property from the person +delete person.size + // 3. Increase the person's age by 11 +person.age+=11 // 4. Add an instruments property to the person, initialised as an empty array +person.instruments=[] + // 5. Add the following instruments to the persons instruments array: Guitar, Piano, Vocals +person.instruments.push('Guitar', 'Piano','Vocals') // 6. Using an index on the instruments array, set the mainInstrument variable below // to the third instrument in the array -const mainInstrument = undefined +const mainInstrument = person.instruments[2] + // 7. Add a profession property to the person, which is an object +person.profession={} // 8. Add a name property to the profession object with the value Musician +person.profession.name='Musician' // 9. Add a friends property to the person, which is an empty array +person.friends=[] // 10. Add two objects to the persons friends array with the following properties: // Friend one: name - Chris, age - 46 // Friend two: name - Dom, age - 43 +person.friends.push({name:'Chris', age: 46}, {name:'Dom', age: 43}) + // 11. Using an index on the persons friends array, set the bestFriend variable below // to the name of the first friend in the array -const bestFriend = undefined +const bestFriend = person.friends[0].name // Don't change the code below this line module.exports = { person, mainInstrument, bestFriend -} +} \ No newline at end of file From 25173078f9d214800a40b2065d2c8a02b33153fc Mon Sep 17 00:00:00 2001 From: TMajlu Date: Tue, 8 Oct 2024 14:40:06 +0200 Subject: [PATCH 2/2] Thomas Nielsen --- .husky/pre-commit | 4 ---- .idea/.gitignore | 3 +++ .idea/js-fundamentals-objects.iml | 9 +++++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ src/core.js | 18 ++++++++++++++++-- src/extension.js | 21 ++++++++++++++++----- 8 files changed, 64 insertions(+), 11 deletions(-) delete mode 100644 .husky/pre-commit create mode 100644 .idea/.gitignore create mode 100644 .idea/js-fundamentals-objects.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 6b54e0b..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx eslint src diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/js-fundamentals-objects.iml b/.idea/js-fundamentals-objects.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/js-fundamentals-objects.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..82a30ab --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/core.js b/src/core.js index 6380dd5..d9b91a9 100644 --- a/src/core.js +++ b/src/core.js @@ -2,32 +2,46 @@ const person = { age: 32, size: 'Small' } // 1. Give the person object a name property with the value Matt +person.name='Matt' + // 2. Remove the size property from the person +delete person.size + // 3. Increase the person's age by 11 +person.age+=11 // 4. Add an instruments property to the person, initialised as an empty array +person.instruments=[] + // 5. Add the following instruments to the persons instruments array: Guitar, Piano, Vocals +person.instruments.push('Guitar', 'Piano','Vocals') // 6. Using an index on the instruments array, set the mainInstrument variable below // to the third instrument in the array -const mainInstrument = undefined +const mainInstrument = person.instruments[2] + // 7. Add a profession property to the person, which is an object +person.profession={} // 8. Add a name property to the profession object with the value Musician +person.profession.name='Musician' // 9. Add a friends property to the person, which is an empty array +person.friends=[] // 10. Add two objects to the persons friends array with the following properties: // Friend one: name - Chris, age - 46 // Friend two: name - Dom, age - 43 +person.friends.push({name:'Chris', age: 46}, {name:'Dom', age: 43}) + // 11. Using an index on the persons friends array, set the bestFriend variable below // to the name of the first friend in the array -const bestFriend = undefined +const bestFriend = person.friends[0].name // Don't change the code below this line module.exports = { diff --git a/src/extension.js b/src/extension.js index 38f327f..3d17bcf 100644 --- a/src/extension.js +++ b/src/extension.js @@ -16,13 +16,18 @@ const book = { } /* eslint-disable no-unused-vars */ -const isbn13 = '978-0132350884' +book.isbn.isbn13 = '978-0132350884' // 1. Set this to the book name - using the book object -const name = '' +book.category = 'Programming' +book.pages = 464 +delete book.dimensions +delete book.isbn.asin +book.isbn.isbn10 = '9780132350884' +const name = book.name // 2. Set this to the isbn 10 value - using the book object -const isbn10 = '' +const isbn10 = book.isbn.isbn10 // Do not modify this basket object directly const basket = { @@ -42,10 +47,16 @@ const basket = { } // 3. Set this variable to the length of the baskets voucher codes array - using the basket object -const numberOfVoucherCodes = null +basket.items[0].price = 2 +basket.items.push({ + name: 'Oranges', + quantity: 4, + price: 0.75 +}) +const numberOfVoucherCodes = basket.voucherCodes.length // 4. Set this variable to the first element in of the baskets voucher codes array - using the basket object -const firstVoucherCode = null +const firstVoucherCode = basket.voucherCodes[0] // Do not edit this exported object module.exports = {