scrimba
Note at 1:31
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 1:31
AboutCommentsNotes
Note at 1:31
Expand for more info
main.js
run
preview
console
function arrayPreviousLess(nums) {
let smth = []
nums.reverse().map((a,b)=> a>nums[b+1] ? smth.push(nums[b+1]) : smth.push(-1))
return smth.reverse()
}



/**
* Test Suite
*/
describe('arrayPreviousLess()', () => {
it('shift previous postions from the left to a smaller value or store -1', () => {
// arrange
const nums = [3, 5, 2, 4, 5];

// act
const result = arrayPreviousLess(nums);

// log
console.log("result: ", result);

// assert
expect(result).toEqual([-1, 3, -1, 2, 4]);
});
});
Console
"result: "
,
/index.html
LIVE