Reverse

Benchmark created on


Setup

const sentence = 'Lorem Ipsum Dolor Sit Amet'

Test runner

Ready to run.

Testing in
TestOps/sec
test1
// Write an answer using console.log()
// To debug: console.error('Debug messages...');
const parts = sentence.split(' ').reverse().join(' ');
console.log(parts);
ready
test2
const split = sentence.split(' ');
let result = ''
for(let i=split.length -1; i >=0 ; i-- )
{
    result += split[i];
        if(i > 0) result += ' ';
}

// Write an answer using console.log()
// To debug: console.error('Debug messages...');

console.log(result);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.