Skip to content

completed sprint challenge #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
73 changes: 54 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +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: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
(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. */


const vincentVanDough = artists[8].name = "Vincent Van Gogh"
// console.log(vincentVanDough)

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use getArtistByIndex to do the following:
Expand All @@ -228,12 +229,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(artists, id) {
return `the artist at index ${id} is ${artists[id].name}`
}



/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use get20s to do the following:
1. Receive an array
Expand All @@ -243,11 +243,17 @@ Example born in 1901 and died in 1959 - included -- born in 1889 and died in 192
If correct, the function should return ["Salvador Dali", "Frida Kahlo"]*/
// Hint - Look up the .split() method

function get20s(/*Your Code Here*/) {
/*Your Code Here*/
function get20s(artists) {
let artists20s = []
for (let i = 0; i < artists.length; i++){
let years = artists[i].years.split(' - ')
if (years[0] >= 1900 && years[1] <= 2000){
artists20s.push(artists[i].name)
}
} return artists20s
}


// console.log(get20s(artists))

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use removeArtist to do the following:
Expand All @@ -258,8 +264,9 @@ Use removeArtist to do the following:

For example, if removeArtist is invoked with the artists array and the number 0, it will remove Amedeo Modigliani from our dataset and return the number 19. */

function removeArtist(/*Your Code Here*/) {
/*Your Code Here*/
function removeArtist(artists, id) {
artists.splice(id, 1)
return artists.length
}


Expand All @@ -279,10 +286,22 @@ Use addArtist to do the following:

Example: addArtist(artists) 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) {
const newArtist =
{
id: 20,
name: 'Aviance Obie',
years: '1997 - present day',
genre: 'Web Design',
nationality: 'United States',
bio: 'Aviance was born in Houston, TX. She is not an artist, but she studies Spanish and travels in her free time.'
}
artists.push(newArtist)
return artists
}

// addArtist(artists)
// console.log(artists[20])


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -292,10 +311,16 @@ Use lotsOfArt to do the following:

For example lotsOfArt(artists); will return ["Amedeo Modigliani", "Rene Magritte", ... "Albrecht Dürer"]*/

function lotsOfArt(/*Your Code Here*/) {
/*Your Code Here*/
function lotsOfArt(artists) {
let lotsOfPaintings = []
for (let i = 0; i < artists.length; i++){
if (artists[i].paintings > 100){
lotsOfPaintings.push(artists[i].name)
}
} return lotsOfPaintings
}

console.log(lotsOfArt(artists))

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 8: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use artistInfo to do the following:
Expand All @@ -306,8 +331,13 @@ Use artistInfo to do the following:
For example artistInfo(artists, 'Frida Kahlo') will return:
["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, artistName){
let artistBio = []
for (let i = 0; i < artists.length; i++){
if (artists[i].name === artistName){
artistBio.push(artists[i].bio)
}
} return artistBio
}


Expand All @@ -321,8 +351,13 @@ Use artistByCountry to do the following:
For example artistByCountry(artists, 'Spanish') will return: [ 'Salvador Dali', 'Pablo Picasso', 'Francisco Goya']
*/

function artistByCountry(/*Your Code Here*/){
/*Your Code Here*/
function artistByCountry(artists, artNationality){
let artNames = []
for (let i = 0; i < artists.length; i++){
if (artists[i].nationality === artNationality){
artNames.push(artists[i].name)
}
} return artNames
}


Expand Down
Loading