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
Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
kolbaska11 [484]

Answer: Decoupling action of the process address space refers to the physical memory of the device getting decoupled to provide  address translation in automatic way. The benefit of this method is as follows:-

  • Faster starting up of the program
  • The physical address space gets managed on its own
  • Helps in execution of large program when the main memory of the machine is of  smaller size in comparison with program

7 0
4 years ago
Technician A says a modern automobile has more than 1 mile of wiring. Technician B says there could be more than 1,000 individua
FinnZ [79.3K]
Both because if you put all of the wires from end to end there is more then one mile of wiring 
7 0
3 years ago
What are the three main components of an IF function?
Lesechka [4]
Test somthing such as the value in a cell
4 0
3 years ago
Which operating system is a version of Linux?​
Lunna [17]

Answer:

MS-DOS

Explanation:

The only operating system which is a version of Linux.

3 0
3 years ago
Which statement describes what happens if multiple users make changes simultaneously to a presentation when coauthoring?
Marina CMI [18]

Answer:

3.

Explanation:

Co-authoring in PowerPoint is sharing a presentation and allowing your colleagues to work on it at the same time. This option of co-authoring is available when you share or save your file on OneDrive or SharePoint.

The perk of co-authoring a presentation is that PowerPoint keeps a record of all edits under the name of the author. This keeps the conflicts away.

Therefore, the correct answer is option 3.

8 0
3 years ago
Other questions:
  • Which of the following is NOT a group on the Slide Master tab?
    6·1 answer
  • Explain the purpose of the frame check sequence (fcs) field in a data link frame trailer.
    7·1 answer
  • A Network Management Station (NMS) is using SNMP to manage some Cisco routers and switches with SNMPv2c. Which of the following
    10·2 answers
  • Describe how computers are used to access, retrieve, organize, process, maintain, interpret, and evaluate data and information.
    13·1 answer
  • How can i change my age on my profile here bc i am 13 but i accidenlty put 2005 instead of 2006 no need to rush to answer just w
    9·2 answers
  • What are ya'll discords???
    10·2 answers
  • Give a non-network example of hierarchical addressing and discuss how it reduces the amount of work needed in physical delivery.
    10·1 answer
  • Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
    7·1 answer
  • What do you notice about the cinematography
    14·1 answer
  • Which three IP addresses may be pinged by the Test Management Network feature in the ESXi hosts DCUI
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!