Last active
July 23, 2022 00:26
-
-
Save cihat/18bc14b4a7d5043564b29c67b6b9027f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const list = []; | |
function fixStream(streams) { | |
let count_order = 0; | |
let total = 0; | |
let stream_group = []; | |
streams = [].concat(...streams); | |
streams.forEach((item, i, stream) => { | |
total = 0; | |
if (count_order % 3 === 0) { | |
stream_group.push( | |
Number(stream[i]), | |
Number(stream[i + 1]), | |
Number(stream[i + 2]) | |
); | |
stream_group = stream_group.filter( | |
(item) => !(isNaN(Number(item)) || item === null) | |
); | |
total = stream_group.reduce((a, b) => a + b, 0); | |
if (total > 90) list.push(total); | |
stream_group = []; | |
} | |
count_order++; | |
}); | |
return list; | |
} | |
let stream_one = ['90', '20', null, null, null, '20', '35', '90', '60']; | |
let stream_two = ['34', 'Can', 'asdfasdf', 'Test', 'Veli', '20', '20', '15']; | |
let stream_three = ['75', '95', '0', '0', '20', '43', '0', '-15']; | |
let stream_four = ['25', '43', '105', '23', '-5']; | |
let stream_new = ['25', '43', '105', '23', '-5', '23']; | |
const dummy_streams_data = [ | |
stream_one, | |
stream_two, | |
stream_three, | |
stream_four, | |
[...stream_new], | |
]; | |
const result = fixStream(dummy_streams_data); | |
console.log(result); | |
/* [ 110, 185, 110, 95, 123, 173 ] */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment