1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anon25 [30]
4 years ago
6

Write a function called removePartyKillers that takes in an array like "playlist" (see below) and returns a copy of that playlis

t where any song longer than 8 minutes has been removed. You can safely assume that a playlist is an array of objects. Each object will have the properties title, artist, and durationInSeconds.
var awesomePlaylist = [
{
title: "Hay Day",
artist: "Robo-Crop",
durationInSeconds: 378
}, {
title: "10,000 Pounds",
artist: "L-Ton Jonn",
durationInSeconds: 498,
}, {
title: "Caesar's Salad",
artist: "DJ Dinner Julius",
durationInSeconds: 600,
}, {
title: "The British Are On Their Way",
artist: "Raul Pevere",
durationInSeconds: 1095,
}, {
title: "13th",
artist: "The Doctors",
durationInSeconds: 185,
}
];
function removePartyKillers(playlist) {

}
removePartyKillers(awesomePlaylist);
Would return:

[
{
title: "Hay Day",
artist: "Robo-Crop",
durationInSeconds: 378
}, {
title: "13th",
artist: "The Doctors",
durationInSeconds: 185,
}
]
Computers and Technology
1 answer:
Nostrana [21]4 years ago
8 0

Answer:

function removePartyKillers(playlist){

for(var i=0; i < playlist.length; i++){

if((playlist[i].durationInSeconds) > 480){

playlist.splice(i, 1);

}

}

console.log(playlist);

}

Explanation:

When 8 minutes is converted to seconds, we have 480 seconds, that is 60 * 8 = 480. So, song whose duration is greater than 480 is removed.

The function has a for loop that loop through the entire playlist.

Inside the for loop, there is an if statement that check if for each song the durationInSeconds is greater than 480; once a durationInSeconds is greater than 480, that particular element is removed using the splice inbuilt method.

The splice method takes two arguments, the index at which to remove/add an element and the second element which is the number of elements to remove/add. The splice method returns a modified array.

Lastly, the modified array is logged to the console.

You might be interested in
Write a java program that accepts the ingredients for a recipe in cups and converts to ounces
Tanzania [10]

Answer:

Explanation:

public static int cupsToOunces (int cups) {

   

       int ounces = cups * 8;

       return ounces;

       

   }

This is a very simple Java method that takes in the number of cups in the recipe as a parameter, converts it to ounces, and then returns the number of ounces. It is very simple since 1 cup is equal to 8 ounces, therefore it simply takes the cups and multiplies it by 8 and saves that value in an int variable called ounces.

6 0
3 years ago
(I'm on my computer btw)why won't Brainly let me message people?
IrinaVladis [17]

Answer:

i do not know i want to do the same thing but it says start answering questions when like i helped a lot of people

Explanation:

6 0
3 years ago
Read 2 more answers
Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes rece
nydimaria [60]

Answer:

The following fix were made to the program

  1. Change void main() to int main(), then set a return value at the end of the main function;  e.g. return 0
  2. Remove system("pause");  It's not needed
  3. For each of the array, change their lengths to 5 i.e. int votes[5];  string name[5];   and float percent[5];
  4. Lastly, calculate the percentage using: percent[i]=((votes[i]*100.0/total))

Explanation:

(1) void main implies that the main function will not return any value. So, you change it to int main() and then set the return value

(2) There is no need to pause the program, so system.("pause") is not necessary.

(3) The question says there are 5 candidates. So, we set the arrays to accommodate inputs for 5 values

(4) percent array is declared as float; 100.0 will ensure that it calculates the percentage as a float value.

<em>See attachment for updated code</em>

Download cpp
3 0
3 years ago
Assume that an array of integers named a that contains exactly five elements has been declared and initialized. Write a single s
Alik [6]

array[0] = 2 * array[4];

5 0
3 years ago
Imagine that you are helping a customer needing technical assistance for a printer they recently purchased. They bought the prin
hodyreva [135]
1. Ask if the printer is plugged in
2. Try a different power cord.
3. If none of the other thing work try a return using the warranty. 
7 0
3 years ago
Other questions:
  • If you like to spend time outdoors working with plants and animals, you have a(n) _____. a. bodily/kinesthetic learning style b.
    6·2 answers
  • The main thing that adjusting the aperture controls when taking an image is?
    15·1 answer
  • Are there protections for people in terms of what data can be collected by different sites?
    10·1 answer
  • This diagram shows a number of computing devices connected to the Internet with each line representing a direct connection.
    11·1 answer
  • True or false? pressing Ctrl and S is a shortcut for saving
    15·2 answers
  • A company wants to inform a select list of it's regular customers about a flash sale. Which type of platform will it use to send
    9·1 answer
  • A client calls to complain that his computer starts up, but crashes when Windows starts to load. After a brief set of questions,
    13·1 answer
  • Which of the following is referred to as "keeping up with the Joneses"?
    13·1 answer
  • Ok answer me this who do you like better sans or paapyrus? If its another au say wich one P.S. I picked computers bc its a game
    14·1 answer
  • What are the uses of navigation keys​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!