Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 621 Bytes

convert-last-three-falses-to-true.md

File metadata and controls

17 lines (13 loc) · 621 Bytes

Convert Last Three Falses to True

Create a function that accepts a boolean array and converts the last 3 false values to true.

If there are 3 or less than 3 false values in the array it converts all of them to true.

The function should return the updated array.

function convertLastThree(bools){
// write your code here
}
let booleans = [true, false, true, false, true, false, false, false, true, false];

console.log(convertLastThree(booleans));// [true, false, true, false, true, false, true, true, true, true]
booleans = [false,false,true];
console.log(convertLastThree(booleans));// [true, true, true]