exercism / javascript

Exercism exercises in JavaScript.

Home Page:https://exercism.org/tracks/javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Annalyns infiltration

R0N1n-dev opened this issue · comments

Error on testing response

SyntaxError: <solution>/annalyns-infiltration.js: 'import' and 'export' may only appear at the top level. (82:0)

      80 |  * @returns {boolean} Whether or not you can free Annalyn's friend.
      81 |  */
    > 82 | export function canFreePrisoner(
         | ^
      83 |   knightIsAwake,
      84 |   archerIsAwake,
      85 |   prisonerIsAwake,

The code includes the 'export' tag.

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

It looks like the code was pasted in some environment unsupported by Exercism.

Please use the web editor or use the instructions provided by the track installation documentation.

export function canExecuteFastAttack(knightIsAwake) {
  return knightIsAwake != true;
}

export function canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake) {
  return (knightIsAwake == true || archerIsAwake == true || prisonerIsAwake && true);
}

export function canSignalPrisoner(archerIsAwake, prisonerIsAwake) {
  return archerIsAwake == false && prisonerIsAwake == true;
}

export function canFreePrisoner( knightIsAwake, archerIsAwake, prisonerIsAwake, petDogIsPresent) {
  return (archerIsAwake == false && petDogIsPresent == true) ||
  (prisonerIsAwake == true && archerIsAwake == false && knightIsAwake == false && petDogIsPresent == false);
}

PS there are some errors...

Am in the site. That's where this error generated as I ran tests for the final function. And they all have export on them.

The export "tag" is not the issue. The error occurs when you try to run it somewhere else, or if the export is nested e.g.

// This is called top-level
export function something() {
  
  // This is not top-level
  export function somethingElse() {
    // ...
  }
  
}