test1

Benchmark created on


Setup

vindLangsteWoord("a aa aaa aaaa aaaaa");

Test runner

Ready to run.

Testing in
TestOps/sec
eigenTest
        let vindLangsteWoord = (string) => {
            let wA = string.split(" ");
            let lA = [];

            for(let w of wA) {
                lA.push(w.length);
            }

            let pos = lA.indexOf(Math.max(...lA));
            console.log(`Het langste woord in de zin is ${wA[pos]} met ${lA[pos]} karakters.`);
        }
ready
oplTest
vindLangsteWoord = (string) => {
            let aSplit = string.split(' ');
            let lenLangsteWoord = 0;
            let langsteWood = '';

            for (let i = 0; i < aSplit.length; i++) {
                if (aSplit[i].length > lenLangsteWoord) {
                    lenLangsteWoord = aSplit[i].length;
                    langsteWood = aSplit[i];
                }
            }
            //res.innerHTML = 'Het langste woord is "' + langsteWood + '" met ' + lenLangsteWoord + ' karakters';
            console.log('Het langste woord is "' + langsteWood + '" met ' + lenLangsteWoord + ' karakters')
        }
ready

Revisions

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