Here's an example JavaScript code snippet that replaces all occurrences of -1
in an age
array with NaN
:
index.tsx86 chars6 lines
In this code, we iterate through the age
array using a for loop, and use an if condition to check if the current value is -1
. If it is, we replace it with NaN
. Note that NaN
is a special value in JavaScript that represents "Not a Number".
gistlibby LogSnag