From ab7fba567280923e6980b32090897a62c695df7f Mon Sep 17 00:00:00 2001 From: james starling Date: Fri, 30 Sep 2022 14:31:46 -0400 Subject: [PATCH 1/2] completed sprint 1 challenge, some conosle logs are correct but auto test says otherwise --- index.js | 66 ++++++++++++++++++++++++++++++++--------------- package-lock.json | 4 +-- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index a9560baa3..36f7464c3 100644 --- a/index.js +++ b/index.js @@ -208,18 +208,18 @@ Practice accessing data above by console.log-ing following items: (no functions needed) */ //(1) Name of the first artist (0th index) in the array - +console.log(artists[0].name); //(2) Bio of the third artist (2nd index) in the array - +console.log(artists[2].bio); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 2 (not auto tested): πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ (no function needed) There is a typo in your dataset 😱 The 9th artist, Vincent Van Gogh is currently Vincent Van Dough. Fix this issue and console.log() to check your work. */ - - +artists[9].bio = "Vincent Willem van Dough (Dutch: [ˈvΙͺnsΙ›nt ΛˆΚ‹ΙͺlΙ™m vΙ‘Ε‹ ΛˆΙ£Ι”x] (listen); 30 March 1853 – 29 July 1890) was a Dutch Post-Impressionist painter who is among the most famous and influential figures in the history of Western art. In just over a decade he created about 2,100 artworks, including around 860 oil paintings, most of them in the last two years of his life. They include landscapes, still lifes, portraits and self-portraits, and are characterised by bold colours and dramatic, impulsive and expressive brushwork that contributed to the foundations of modern art. However, he was not commercially successful, and his suicide at 37 followed years of mental illness and poverty." +console.log(artists[9].bio); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 3: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Use getArtistByIndex to do the following: @@ -230,9 +230,11 @@ 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(array, number) { + return `the artist at index ${array[number].id} is ${array[number].name}` } +console.log( 'task3', getArtistByIndex(artists, 0)); +console.log( 'task3', getArtistByIndex(artists, 2)); @@ -244,9 +246,10 @@ 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(array) { + return (array.filter(a => a.name).map(a => a.name)); + } +console.log('task4 ', listOfNames(artists)); @@ -259,10 +262,15 @@ 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(array,index) { + let array2 = array + array2.shift(index); + return array; + } +console.log(removeArtist(artists,0)); + /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 6: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -281,9 +289,19 @@ 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(array, name, year, genre, nationality, bio) { + let object = { + name : name, + years: year, + genre: genre, + nationality : nationality , + bio : bio + } + let array3 = array; + array3.push(object); + return array3; + } + console.log(addArtist(artists, 'james', 1997, 'web design', 'mixed', 'just trying to make a way for my family for the future. this is a growing field of work')); @@ -295,10 +313,12 @@ 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(array, paintings) { + let artarray = array + return (artarray.filter(a => a.paintings >= paintings).map(a => a.name)); + } - +console.log(lotsOfArt(artists,100)); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 8: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -311,10 +331,12 @@ 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(array, name){ + let artarr = array; + return (artarr.filter(a => a.name === name).map(a => a.bio)); } +console.log(artistInfo(artists,"Kazimir Malevich")); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 9: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -327,9 +349,11 @@ 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(array, county){ + let array5 = array; + return( array5.filter(a => a.nationality === county).map(a => a.name)); } +console.log(artistByCountry(artists,'Spanish')); 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 3fe9f8a0bbf095b16be2ba19d90ab1d1a3b5d2f8 Mon Sep 17 00:00:00 2001 From: james starling Date: Sat, 1 Oct 2022 11:59:57 -0400 Subject: [PATCH 2/2] fixed mistakes ready for next sprint! --- index.js | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 36f7464c3..31c8e14c2 100644 --- a/index.js +++ b/index.js @@ -313,12 +313,17 @@ Use lotsOfArt to do the following: 🌟 EXAMPLE: lotsOfArt(artists) will return ["Amedeo Modigliani", "Rene Magritte", ... "Albrecht DΓΌrer"] */ -function lotsOfArt(array, paintings) { - let artarray = array - return (artarray.filter(a => a.paintings >= paintings).map(a => a.name)); - +function lotsOfArt(artists) { + let lots2art = [] + for (let i = 0; i < artists.length; i++){ + let paintings = artists[i].paintings + if(paintings >= 100){ + lots2art.push(artists[i].name) + } } -console.log(lotsOfArt(artists,100)); +return lots2art +} +console.log(lotsOfArt(artists)); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 8: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -331,11 +336,13 @@ 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(array, name){ - let artarr = array; - return (artarr.filter(a => a.name === name).map(a => a.bio)); +function artistInfo(artists, name){ + for (let i = 0; i < artists.length; i++){ + if (artists[i].name === name){ + return artists[i].bio + } +} } - console.log(artistInfo(artists,"Kazimir Malevich")); @@ -349,11 +356,16 @@ Use artistByCountry to do the following: 🌟 EXAMPLE: Invoking artistByCountry(artists, 'Spanish') will return: [ 'Salvador Dali', 'Pablo Picasso', 'Francisco Goya'] */ -function artistByCountry(array, county){ - let array5 = array; - return( array5.filter(a => a.nationality === county).map(a => a.name)); +function artistByCountry(array, nationality){ + const nartArray = []; + for(let i =0; i < array.length; i++){ + if(array[i]["nationality"] === nationality){ + nartArray.push(array[i]["name"]); + } + } + return nartArray } -console.log(artistByCountry(artists,'Spanish')); +console.log(artistByCountry(artists, 'Spanish'));