0

Как отфильтровать массивы по часам которые больше 3?

let amount = 100;
let monday = [
  ['Write a tutorial',180],
  ['Some web development',120]
];
let tuesday = [
  ['Keep writing that tutorial',240],
  ['Some more web development',180],
  ['A whole lot of nothing',240]
];

let tasks = [monday,tuesday];

let converted = tasks.map( arr => {
  return arr.map( arr => {
    return [ arr[0], Math.ceil(arr[1]/60) ]
  })
});

console.log(converted);
2
  • 1
    Со входящими понятно. Что на выходе должно получиться? Дополните вопрос примером.
    – UModeL
    21 фев 2021 в 16:41
  • На выходе должны быть массивы которые переведены с минут в часы но отобразить только те которые больше 3 часов. 21 фев 2021 в 16:53

1 ответ 1

2

Поправьте, если неправильно понял:

let monday = [
  ['Write a tutorial', 180],
  ['Some web development', 120],
];
let tuesday = [
  ['Keep writing that tutorial', 240],
  ['Some more web development', 180],
  ['A whole lot of nothing', 240],
];

let tasks = [monday, tuesday];

let converted = tasks.map(
  arr => arr.filter(([, minutes]) => minutes > 180)
            .map(([text, minutes]) => [text, Math.ceil(minutes / 60)])
);

console.log(converted);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.