Last active
June 28, 2020 14:05
-
-
Save joefearnley/adef67165c0beea72b477f0ed6c5caa3 to your computer and use it in GitHub Desktop.
10 day JS challenge - Day: 4: Array Replace
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
const arrayReplace = (array, elemToReplace, substitutionElem) => array.map((el, i) => el === elemToReplace ? substitutionElem : el); | |
describe('arrayReplace()', () => { | |
it('adds a border around entire application', () => { | |
// arrange | |
const array = [1, 2, 1]; | |
const elemToReplace = 1; | |
const substitutionElem = 3; | |
// act | |
const result = arrayReplace(array, elemToReplace, substitutionElem); | |
// log | |
console.log("result: ", result); | |
// assert | |
expect(result).toEqual([3, 2, 3]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment