Create an Export Fallback with export default - ON ONE LINE?

Create an Export Fallback with export default - ON ONE LINE?
0

#1

Tell us what’s happening:
Hi, can someone explain why this code is working only if is on one line? Im doing solutions in external editor and code is placed on multiple lines as in example. but when I place code to FCC editor code doesn’t pass. So I am confused. Test PASS only when code is on one line.

Your code so far


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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

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


#2

Many times the tests want you to write the code only the way they want, even if other ways are much cleaning or efficient. You will find these kind of things many times through the curriculum, but don’t worry, your code is fine; you just need to give the tests what they want to see.

In the future, if you’re certain your code is alright, visit the forum and look for that challenge to check if there’s an issue around the tests in that challenge.


#3

Sometimes even a space matters :slight_smile:


#4

I aware of some possible “problems” with spacing (lint) but in this case it was so weird that I get confused. :slight_smile: So Im glad thats its not my code but their environment. Is’t like if teacher ask you for result of 2+2 and on your answer “Is 4” teachers says “Really?”. Thanks for clarifying these possible glitches.