Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sum All Odd Fibonacci Numbers: gives an error when I use console.log() #8468

Closed
Y-Taras opened this issue May 5, 2016 · 2 comments
Closed

Comments

@Y-Taras
Copy link

Y-Taras commented May 5, 2016

Challenge Sum All Odd Fibonacci Numbers has an issue.
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:42.0) Gecko/20100101 Firefox/42.0.
Please describe how to reproduce this issue, and include links to screenshots if possible.
**
#1 Mozilla v.42 :               SyntaxError: missing while after do-loop body;
#2 Google Chrome v.47 : SyntaxError: Unexpected token;

Without strings with console.log it works fine.**

My code:

function sumFibs(num) {
    var arr = [];
    var i = 0;
    var sum = 0;
    do {
        if (i <= 1) {
            arr.push(i);
            console.log('arr[', i, ']', arr[i]);
        } else {
            arr.push(arr[i - 1] + arr[i - 2]);
            console.log('arr[', i, ']', arr[i]);

        }

        if (arr[i] > num) { break;}


        if ((arr[i] % 2) !== 0) {
            sum += arr[i];
        }

        i += 1;

    } while (i);

    return sum;
}
sumFibs(4);
@raisedadead
Copy link
Member

@Y-Taras Thanks for reporting this.
A library looprotect that we use is conflicting with this solution.
You can pass this challenge by adding //noprotect on the top of your code.

This is the looprotect output, at line no 5, there is a conflict.

function sumFibs(num) {
    var arr = [];
    var i = 0;
    var sum = 0;
    ;loopProtect.protect({ line: 7, reset: true }); do {;
if (loopProtect.protect({ line: 7 })) break;

        if (i <= 1) {
            arr.push(i);
            console.log('arr[', i, ']', arr[i]);
        } else {
            arr.push(arr[i - 1] + arr[i - 2]);
            console.log('arr[', i, ']', arr[i]);

        }

        if (arr[i] > num) { break;}


        if ((arr[i] % 2) !== 0) {
            sum += arr[i];
        }

        i += 1;

    } ;loopProtect.protect({ line: 26, reset: true }); while (i){
if (loopProtect.protect({ line: 26 })) break;
;
}


    return sum;
}
sumFibs(4);

@raisedadead
Copy link
Member

Just checked this is an known issue with loopProtect sadly, reported back in #5162
Closing this in favor of the older issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants