Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array replace javascript

function solution(inputArray, elemToReplace, substitutionElem) {
    return inputArray.map((item) => {
        if (item === elemToReplace) {
            return substitutionElem;
        }
        return item;
    });
}
 
PREVIOUS NEXT
Tagged: #array #replace #javascript
ADD COMMENT
Topic
Name
3+2 =