educative.io

Replace all Negative Numbers with Zero

A reader asked us the following question:

should function “replace” return an array? The functions does not seem to return anything. Is this correct?

Hi,

This is Wasif Ibrahim from Educative. Thank you for reaching out to us!

In response to your query, the function “replace” has “return;” statement in it but it’s not supposed to return an array or anything else. So even if you exclude “return”, it won’t matter. So it’s correct that the function is not supposed to return anything.

2 Likes