Quick Coding Test
Please write code to change seconds_batches to be sorted_uniq_seconds in simplest way in Javascript
by oktaviardi pratama
HTML
<h3>
expected
</h3>
<p>
[1, 2, 3, 4, 5, 6, 7, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
</p>
<h3>
result:
</h3>
<p id="result">
</p>
JavaScript
const seconds_batches = [
[1, 2, 3, 4],
[1, 2, 3, 4, 5, 6, 7],
[30, 31, 32, 33],
[1, 2, 3, 32, 33, 34, 35, 36, 37, 38, 39, 40],
]
let sorted_uniq_seconds = Array.from(new Set(seconds_batches.flat().sort((a,b) => a-b)))
document.getElementById('result').innerHTML = sorted_uniq_seconds;