question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Semicolon on while statement causes challenge failure

See original GitHub issue

Challenge Name

https://www.freecodecamp.com/challenges/smallest-common-multiple

Issue Description

Using the sample solution in the wiki article for this algorithm, for a do…while loop, if you include the required semicolon after the while, you get “SyntaxError: Unexpected token ;”. If you take the semicolon out, you get a stop sign on the line saying that the semicolon is missed, but the challenge passes.

Browser Information

  • Browser Name, Version: Chrome, 52.0.2743.60 beta-m
  • Operating System: WIndows 10 Home
  • Mobile, Desktop, or Tablet: Desktop

Your Code

   do {
    quot = newArr[0] * loop * newArr[1];
    for (n = 2; n < newArr.length; n++) {
      if (quot % newArr[n] !== 0) {
        break;
      }
    }

    loop++;
  } while (n !== newArr.length);

Screenshot

scm

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
raisedadeadcommented, Jul 12, 2016

@flipsyde606: By all means, any issue that’s tagged as Help Wanted is open to all for a fix. You needn’t request permission. Thanks a lot.

0reactions
raisedadeadcommented, Jul 13, 2016

@flipsyde606: If this is a bug in the loop-protect library then we can log a issue on their repo. But I am not sure that its very well maintained. The published fork on npm is a fork of the original.

Anyways: Option 1 and Option 2 are a strict NO GO.

Option 3 is a work around, but we still would need to detect this for do…while loops. Of course we can tell the campers to use this in all algorithm challenges but then that beats the purpose of having it in the first place.

/cc @FreeCodeCamp/issue-moderators thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

My C language code contains a line as follows: while ... - Quora
C is designed to ignore line endings. The compiler responds only to the semicolon to complete a statement. The C pre-processor does respond...
Read more >
Trivial Do While Loop - C2 wiki
A trivial do/while loop is a useful device in CeeLanguage consisting of a do/while loop with ... because a trailing semicolon will cause...
Read more >
Risks & Errors in While, For & Do While Loops in C - Study.com
The misplaced semicolon can create problems with a while loop. Though this loop looks correct, because there's a semicolon after the while ...
Read more >
What happens if you put a semi colon after while statment in C++
The semicolon after the while statement means a null statement. That is the sub-statement of the while statement is the null statement.
Read more >
Semicolon Inference - Programming Linguistics
Although a semicolon may be specified, it is not required to terminate a statement. This post explores the underlying rules various languages ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found