Skip to content
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

Sprint Completed #309

Open
wants to merge 2 commits into
base: main
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
96 changes: 71 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const artists = [
{
"id": 0,
"name": "Amedeo Modigliani",
Expand Down Expand Up @@ -208,17 +207,19 @@ Practice accessing data above by console.log-ing following items:
(no functions needed) */

//(1) Name of the first artist (0th index) in the array

let firstArtist = artists[0]
console.log("Task 1 A:", firstArtist);


//(2) Bio of the third artist (2nd index) in the array



let bioThirdArtist = artists[2].bio
console.log("Task 1 B:", bioThirdArtist);
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 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[8].name = "Vincent Van Gogh"
console.log("Task 2:", artists[8].name);


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -230,9 +231,14 @@ 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(artistArray, desiredIndex){
let artist = artistArray[desiredIndex];
let artistName = artist.name;
let requiredString = "the artist at index " + desiredIndex + " is " + artistName;
return requiredString;
}
console.log("Task 3:", getArtistByIndex(artists, 8));
console.log("Task 3:", getArtistByIndex(artists, 0));



Expand All @@ -244,10 +250,15 @@ 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(artistArray) {
let copyArtistArray = [...artistArray];
for(let i = 0; i < copyArtistArray.length; i++){
let currentArtistName = copyArtistArray[i].name
copyArtistArray[i] = currentArtistName
}
return copyArtistArray;
}

console.log("Task 4:", listOfNames(artists));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -259,10 +270,12 @@ 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(artistArray, desiredIndex) {
let copyArtistArray = [...artistArray];
copyArtistArray.splice(desiredIndex, 1);
return copyArtistArray;
}

console.log("Task 5:", removeArtist(artists, 0));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -281,10 +294,20 @@ 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(artistArray, name, years, genre, nationality, bio) {
let copyArtistArray = [...artistArray];
let newArtist = {
name: name,
years: years,
genre: genre,
nationality: nationality,
bio: bio,
}
copyArtistArray.push(newArtist);
return copyArtistArray;

}
console.log("Task 6:", 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."));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -295,10 +318,17 @@ 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(artistArray) {
let lostsOfArtNames = []
for(let i = 0; i < artistArray.length; i++){
let currentArtistCount = artistArray[i].paintings
if(currentArtistCount > 100 ){
lostsOfArtNames.push(artistArray[i].name)
}
}
return lostsOfArtNames;
}

console.log("Task 7:", lotsOfArt(artists));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 8: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -311,10 +341,15 @@ 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(artistArray, artistName){
for(let i = 0; i < artistArray.length; i++){
let currentArtistName = artistArray[i].name
if(currentArtistName == artistName){
return artistArray[i].bio
}
}
}

console.log("Task 8:", artistInfo(artists, "Frida Kahlo"));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 9: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -327,10 +362,21 @@ 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(artistArray, nationality){
let artistNames = []
for(let i = 0; i < artistArray.length; i++){
let currentNationality = artistArray[i].nationality
currentNationality = currentNationality.split(",")
if(currentNationality.length > 1){
continue
}
if(currentNationality[0] == nationality){
artistNames.push(artistArray[i].name)
}
}
return artistNames;
}

console.log("Task 9:", artistByCountry(artists, "Spanish"));


/* ***** END OF TASKS ***** */
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.