I have a function that takes an object with 5 arrays as input. One of the properties is named 'Indexes'. The purpose of this function is to fill in the array with zeros in ascending order, where all other arrays follow the Indexes array as their index. For example, if the Indexes array is [1,3], it will be filled with [1,2,3] and all other arrays will have 0 at position 2.
My current issue arises when the Indexes array contains decimals (a requirement for my work). For instance, if I have [43, 44.5, 45], I would like the result to be [43, 44, 44.5, 45]. However, the code I've written seems to skip whole numbers completely, making the process more complex than necessary.
Below is the function:
function fillMissingValues(csv) {
// Function logic here
}
Here's an example of how to pass data to the function:
csv = {
Indexes:[ 3, 4, 6.5, 8],
'All reads': [1, 2, 3, 4],
'Trimmed by Adapter or Quality': [1, 2, 3, 4],
'Trimmed by adapter': [1, 2, 3, 4],
'Trimmed by quality': [1, 2, 3, 4]
}
The expected output should look like this:
filledCSV = {
Indexes:[0, 1, 2, 3, 4, 5, 6, 6.5, 7, 8],
'All reads': [0, 0, 0, 1, 2, 0, 0, 3, 0, 4],
'Trimmed by Adapter or Quality': [0, 0, 0, 1, 2, 0, 0, 3, 0, 4],
'Trimmed by adapter': [0, 0, 0, 1, 2, 0, 0, 3, 0, 4],
'Trimmed by quality': [0, 0, 0, 1, 2, 0, 0, 3, 0, 4]
}