Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array replace javascript

function solution(inputArray, elemToReplace, substitutionElem) {
    return inputArray.map((x) => (x === elemToReplace ? substitutionElem : x));
}
 
PREVIOUS NEXT
Tagged: #array #replace #javascript
ADD COMMENT
Topic
Name
9+7 =