Create a JavaScript Promise - important note for beginners (like me)

I could not figure out why my (simple, one line or so of code wouldn’t work) then I noticed that you are not allowed to have a space between the word Promise and the (

Just thought I would mention it. I thought whitespace didn’t matter, but I guess sometimes it does.

  **Your code so far**

/*

const makeServerRequest = new Promise ((resolve, reject)=>{});//This one does NOT work - you can't have a space between Promise and the opening bracket (

*/

const makeServerRequest = new Promise((resolve, reject) => {});//This one DOES work: no space!
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39

Challenge: Create a JavaScript Promise

Link to the challenge:

I assume that is just a function of the way the FCC test is written. I assume the space is fine in JS (although most people would probably not have a space there.)

It’s a function, that’s how you call functions in JavaScript. Otherwise the thing running the code is going to look at it as a variable called Promise followed by something in brackets. Which works as @kevinSmith says in most cases but it’s more difficult to parse so in tests like this (where the test isn’t just checking that the code works, it need to check that you’ve actually written the expected thing) it’s going to fail – the tests could be adjusted to allow it but it’s unusual to write code like that so :man_shrugging:t3:

1 Like