Created
March 18, 2021 11:37
-
-
Save IlmariKu/c89d8fa474907e1c623a00c2792bf859 to your computer and use it in GitHub Desktop.
Loop unknown amount of nested Javascript arrays and convert all found values to something else.
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
// I used this function to find nested geoJson float values and round the values up to smaller decimals | |
function loopArray(nestedArrays) { | |
return nestedArrays.map(arrayNow => { | |
if (isArray(arrayNow)) { | |
return loopArray(arrayNow) | |
} else if (isNumber(arrayNow)) { | |
return 'your operation here' | |
} | |
}) | |
} | |
const convertedArray = loopArray(unknownNestedArray) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment