Create an Export Fallback with export default

Tell us what’s happening:
I’m trying to complete this ES6 lesson to create an Export Fallback. I thought I typed it in correctly but when I run the code, FCC tells me I didn’t properly use the Fallback. It seems straightforward, am I typing or understanding this wrong?

Your code so far


"use strict";
export default function subtract(x,y) {
    return x-y;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default

1 Like

This could be becasue of FCC strict syntax testing(not sure), but if you place the function in one line(no new lines) it passes, such as following:
export default function subtract(x,y) {return x - y;}

I’m not js expert, but don’t know if newline could affect function or not.

keep going on great work, happy programming

2 Likes

Thanks NULL_dev!
Interestingly enough keeping the function in one line does work. It was just misleading since in the example it seemed like having the function on multiple lines was acceptable.
It also seems like FCC would accept the answer ONLY if there is a space between the fallback function.
for example :
export default function subtract(x,y) {return x - y;}
does NOT work while
export default function subtract(x,y) {return x - y;} (edit: there’s suppose to be a space between x-y but it seems that for this post it just pushes the function together. so it is suppose to display x(space)-(space)y;)
Does anyone know why or is this one of those things that is just because?

1 Like

I don’t want to approve the current way FCC accept answers, but it’s good.

But test cases are about output and result of something, not the way you code it.

But for some syntax checking(so rare in real/enterprise developing world), the way FCC does is kind of fair.

I believe it could be smarter and not so strict to one form of line, but I think it’s fair and good enough.

Hopefully people help people here, and we can find solutions for all problems, it’s great.

Take it easy dear, and keep going on great work. happy programming.

2 Likes

Hi, interresting., but i tried this today and it is working when you set it exactly like that:

export default function subtract(x,y) 
{
  return x - y;
}

But i agree there this is a kind of an issue