Skip to content

The assertion will return actual code output + the normal output , explanation below, hope it helps #829

@mdanro

Description

@mdanro

ACTUALLY IF THE CODE FAILS WITH Maximum call stack size exceeded SUBSEQUENTasserts are wrong

Challenge http://www.freecodecamp.com/challenges/bonfire-no-repeats-please has an issue. Please describe how to reproduce it, and include links to screen shots if possible.

function permAlone(str) {
doPerm(str, []);
return permutations.filter(function (str) {
var repeats = /(.)\1/;
return !repeats.test(str);
}).length;
}
var permutations = [];
function doPerm(str, arr) {
if (typeof (str) == 'string') str = str.split('');
if (str.length === 0) permutations.push(arr.join(''));
for (var i = 0; i < str.length; i++) {
var x = str.splice(i, 1);
arr.push(x);
doPerm(str, arr);
arr.pop();
str.splice(i, 0, x);
}
}
permAlone('aba');

expect(permAlone('zzzzzzzz')).to.equal(0);Maximum call stack size exceeded ???

After first error the subsequent assert calls return correct number + response from the above code
above code returns 2 (CORRECT)

expect(permAlone('aabb')).to.equal(8); will return 8 + 2
Code run alone for 'aabb' will return 8 though...

expect(permAlone('aab')).to.be.a.number;
expect(permAlone('aab')).to.equal(2);
expect(permAlone('aaa')).to.equal(0);
expect(permAlone('aabb')).to.equal(8);
expect(permAlone('abcdefa')).to.equal(3600);
expect(permAlone('abfdefa')).to.equal(2640);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions