JSFiddle - React, Tailwind, and code Playground

by Prathameshsb

JavaScript

const leastDaysToFinishMovies = (durations) => {
	const total = (durations.reduce((a,c) => a + c))/3;
	console.log(total);
};

// Example to run the code
const durations1 = [1.01, 2.4, 1.01, 1.01, 1.4];
console.log(leastDaysToFinishMovies(durations1)); // Output: 3

const durations2 = [1.01, 2.4, 1.4, 1.6, 2.6, 1.7];
console.log(leastDaysToFinishMovies(durations2)); // Output: 4

const durations3 = [1.01, 2.4, 1.5, 1.6, 2.6, 1.7];
console.log(leastDaysToFinishMovies(durations3)); // Output: 5