Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

I need help with console output how to do with JavaScript.

I would like to know what is the console output would be...

function ad(s){
    var j;j=fst(s);
    j+=0.01;
    return j/100;
}

function withtax(a){
    var j,i;i=a>=10?'PA':'';/*j=ad(i);*/a*=1+ad(i);return Math.round(a);
}

function fst(m){
    switch(m) {
        case 'NJ': return 7.52;
        case 'PA' : return 9.99;
        case 'DE': return 3.19;
        case 'CA': return 8.01;
        default:
        return 0;
     }
}

function dnoth(x){
    var i;
    for(j=0;j<5;j++) {
        j%2==0?i*=j:i-=j;
    }
    return โ€“i;
}
     a)      13
     b)      14
     c)       15
     d)      0

4 Answers

15

I was copy and paste into my console. How would you do that because I got an error on console inspect? it said uncaught synataxError: unexpected token ILLEGAL. I was trying with http://jsfiddle.net/ and it was not working at all..

you are having a copy / paste issue. When pasting the current code for the dnoth function you get

function dnoth(x){
    var i;for(j=0;j<5;j++) { 
        j%2==0?i*=j:i-=j; 
    } 
    return รขโ‚ฌโ€œi; 
}

instead of

function dnoth(x){
    var i;for(j=0;j<5;j++) { 
        j%2==0?i*=j:i-=j; 
    } 
    return -i; 
}

Here is a link the working example: https://jsfiddle.net/p84x0c58/

I had a interview in couple of days ago and I took the snapshot. I found out the result last Friday and I failed the test and I learned a lot new of these questions. The question was intermediate to advance level of JavaScript.

thanks you so much for hint answer! I really appreciate for all your helped me.