From 090141432129c84d214aa40c95a0da895e6028b8 Mon Sep 17 00:00:00 2001 From: Robert Franks Date: Wed, 11 Jan 2023 19:47:41 -0600 Subject: [PATCH 1/2] message --- index.js | 77 ++++++++++++++++++++++++++++++++++++----------- package-lock.json | 4 +-- 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index a9560baa3..47b2e1b6b 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ const artists = [ }, { "id": 8, - "name": "Vincent van Dough", + "name": "Vincent van Gogh", "years": "1853 - 1890", "genre": "Post-Impressionism", "nationality": "Dutch", @@ -209,11 +209,11 @@ Practice accessing data above by console.log-ing following items: //(1) Name of the first artist (0th index) in the array - +console.log("The first artist name is " + artists[0].name); //(2) Bio of the third artist (2nd index) in the array - +console.log("The third artist bio is " + artists[2].bio); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 2 (not auto tested): πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ (no function needed) @@ -230,9 +230,13 @@ Use getArtistByIndex to do the following: 🌟 EXAMPLE: if getArtistByIndex is invoked with the artists array and the number 0, it will return `the artist at index 0 is Amedeo Modigliani` */ -function getArtistByIndex(/*Your Code Here*/) { - /*Your Code Here*/ +function getArtistByIndex(artists, artistIntro) { + for(var i = 0; i <= artists.length; i++){ + artistIntro = console.log("The artist at index " + artists[i].id + "is " + artists[i].name ); + } + return artistIntro; } +getArtistByIndex(); @@ -244,10 +248,14 @@ Use listOfNames to do the following: 🌟 EXAMPLE of return: ["Amedeo Modigliani", "Vasiliy Kandinskiy", "Diego Rivera"....] */ -function listOfNames(/*Your Code Here*/) { - /*Your Code Here*/ +function listOfNames(artists) { + const nameList = []; + for(i = 0; i <= artists.length; i++){ + nameList.push(artists[i].name); + } } +listOfNames(); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 5: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -259,8 +267,13 @@ Use removeArtist to do the following: 5. Return the resulting copied array 🌟 EXAMPLE: if removeArtist is invoked with the artists array and the number 0, it will return the resulting array with Amedeo Modigliani removed from our dataset. */ -function removeArtist(/*Your Code Here*/) { - /*Your Code Here*/ +function removeArtist(artists, artistGottaGo) { + let newArray = []; + newArray.push(artists); + artistGottaGo = newArray[4]; + newArray.delete(artistGottaGo); + + return newArray; } @@ -281,8 +294,23 @@ Use addArtist to do the following: 5. Add the newly created object to the copied array, then return the copied array 🌟 EXAMPLE: Invoking addArtist(artists, 'John Doe', '1988-2022', 'Full Stack Development', 'African American', 'I have a background in customer service at Big Retail Chain. I am attending BloomTech to become a Frontend Developer.') should return the artists array with the above object added to the end of the array. */ -function addArtist(/*Your Code Here*/) { - /*Your Code Here*/ +function addArtist(artists, name, years, genre, nationality, bio) { + + const robbie ={ + "name" : "Robbie Franks", + "years" : "1992-present", + "genre" : "Web development", + "nationality" : "American", + "bio" : "I have worked with Publix Supermarkets for the past 9 years, and I'm ready for a change in workflow and tax bracket. Also would be great to spend more time with my wife and kids." + } + + let meArray = []; + + meArray.push(artists); + + meArray.push(robbie); + + return meArray; } @@ -295,8 +323,15 @@ Use lotsOfArt to do the following: 🌟 EXAMPLE: lotsOfArt(artists) will return ["Amedeo Modigliani", "Rene Magritte", ... "Albrecht DΓΌrer"] */ -function lotsOfArt(/*Your Code Here*/) { - /*Your Code Here*/ +function lotsOfArt(artists) { + let soMuchArt =[]; + + for(i = 0; i <= artists.length; i++){ + if (artists[i].paintings >= 100){ + soMuchArt.push(artist[i]); + } + } + return soMuchArt; } @@ -311,8 +346,10 @@ Use artistInfo to do the following: "Frida Kahlo de Rivera (Spanish pronunciation: [ˈfΙΎiΓ°a ˈkalo]; born Magdalena Carmen Frida Kahlo y CalderΓ³n; 6 July 1907 – 13 July 1954) was a Mexican artist who painted many portraits, self-portraits and works inspired by the nature and artifacts of Mexico. Inspired by the country's popular culture, she employed a naΓ―ve folk art style to explore questions of identity, postcolonialism, gender, class and race in Mexican society. Her paintings often had strong autobiographical elements and mixed realism with fantasy. In addition to belonging to the post-revolutionary Mexicayotl movement, which sought to define a Mexican identity, Kahlo has been described as a surrealist or magical realist.Born to a German father and a mestiza mother, Kahlo spent most of her childhood and adult life at her family home in CoyoacΓ‘n, La Casa Azul, now known and publicly accessible as the Frida Kahlo Museum. She was disabled by polio as a child. Until a traffic accident at age eighteen caused lifelong pain and medical problems, she had been a promising student headed for medical school. During her recovery, she returned to her childhood hobby of art with the idea of becoming an artist." */ -function artistInfo(/*Your Code Here*/){ - /*Your Code Here*/ +function artistInfo(artists, artistInfo){ + artistInfo = artists[13].bio; + + return artistInfo; } @@ -327,8 +364,14 @@ Use artistByCountry to do the following: 🌟 EXAMPLE: Invoking artistByCountry(artists, 'Spanish') will return: [ 'Salvador Dali', 'Pablo Picasso', 'Francisco Goya'] */ -function artistByCountry(/*Your Code Here*/){ - /*Your Code Here*/ +function artistByCountry(artists, nationality){ + let nationalArr = []; + for(i = 0; i <= artists.length; i++){ + if(artists[i].nationality === "French"){ + nationalArr.push(artists[i]); + } + } + return nationalArr; } diff --git a/package-lock.json b/package-lock.json index 48103f21c..0f48f45e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codegraded-project-js", - "version": "0.0.8", + "version": "0.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codegraded-project-js", - "version": "0.0.8", + "version": "0.0.9", "devDependencies": { "@babel/core": "7.17.5", "@babel/plugin-transform-runtime": "7.17.0", From 910b70bc623a2ce1bab60a599b582b647a8a9d25 Mon Sep 17 00:00:00 2001 From: Robert Franks Date: Tue, 31 Jan 2023 22:49:20 -0600 Subject: [PATCH 2/2] updated changes --- index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 47b2e1b6b..bc48f7882 100644 --- a/index.js +++ b/index.js @@ -231,12 +231,13 @@ Use getArtistByIndex to do the following: 🌟 EXAMPLE: if getArtistByIndex is invoked with the artists array and the number 0, it will return `the artist at index 0 is Amedeo Modigliani` */ function getArtistByIndex(artists, artistIntro) { - for(var i = 0; i <= artists.length; i++){ - artistIntro = console.log("The artist at index " + artists[i].id + "is " + artists[i].name ); + for(let i = 0; i <= artists.length; i++){ + if(i <= artistIntro){ + console.log("The artist at index " + artists[i].id + " is " + artists[i].name ); + } } - return artistIntro; } -getArtistByIndex(); +getArtistByIndex(artists, 6); @@ -248,10 +249,10 @@ Use listOfNames to do the following: 🌟 EXAMPLE of return: ["Amedeo Modigliani", "Vasiliy Kandinskiy", "Diego Rivera"....] */ -function listOfNames(artists) { - const nameList = []; - for(i = 0; i <= artists.length; i++){ - nameList.push(artists[i].name); +function listOfNames(nameList) { + nameList = []; + for(let i = 0; i <= artists.length; i++){ + nameList.push(artists[i]); } }