mdn / learning-area

GitHub repo for the MDN Learning Area.
https://developer.mozilla.org/en-US/Learn
Creative Commons Zero v1.0 Universal
7.01k stars 27k forks source link

Number Game Errors: Move script inside body tag #775

Closed MaoShizhong closed 6 days ago

MaoShizhong commented 1 week ago

Because

In the "What went wrong?" exercise, there is a warning about line numbers in error messages potentially not matching source code line numbers due to code injection from extensions like live-server.

This is a result of the code's script tag being placed after the closing body tag, so live-server's injected code comes before it.

By placing the script tag before the closing body tag, live-server injects code after it, preserving line numbers in the error messages, making the lesson much easier to follow for more people. The relevant warning can then be removed from the lesson.

This has been tested with VSCode's Live Server extension, VSCode's Live Preview extension and the live-server npm package.

This PR

Additional information

This PR depends on (https://github.com/mdn/content/pull/36541) which amends the line number references and screenshots in the lesson itself to match what these code changes will produce.