Technical Documentation Page - Build a Technical Documentation Page

Tell us what’s happening:
I have met all the user requirements’ but my code can not pass: it tells me that Each .nav-link should have an href attribute that links to its corresponding .main-section (e.g. If you click on a .nav-link element that contains the text “Hello world”, the page navigates to a section element with that id).

Your code so far


The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

``` line above   ``` 

<!DOCTYPE html>
    /* CSS styling and media queries go here */
    @media (min-width: 768px) {
      /* Media query styles for larger screens */
      #navbar {
        position: fixed;
        left: 0;
  <nav id="navbar">
    <header>JS Documentation</header>
    <a class="nav-link" href="#Introduction">Introduction</a>
    <a class="nav-link" href="#JavaScript_and_Java">JavaScript and Java</a>
    <a class="nav-link" href="#Variables">Variables</a>
    <a class="nav-link" href="#if_else_statement">if...else statement</a>
    <a class="nav-link" href="#while_statement">while statement</a>
    <a class="nav-link" href="#Function_declarations">Function declarations</a>
    <a class="nav-link" href="#Reference">Reference</a>

  <main id="main-doc">
    <section id="Introduction" class="main-section">
        JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment (for example, a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.
      <p>Additional paragraph 1.</p>
      <p>Additional paragraph 2.</p>
      <p>Additional paragraph 3.</p>
      <p>Additional paragraph 4.</p>
      <p>Additional paragraph 5.</p>
      <p>Additional paragraph 6.</p>
      <p>Additional paragraph 7.</p>
      <p>Additional paragraph 8.</p>
      <p>Additional paragraph 9.</p>
      <p>Additional paragraph 10.</p>
      <code>const example = 'This is an example';</code>
      <code>function add(a, b) { return a + b; }</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>
      <code>// Additional code 3</code>

    <!-- Rest of the sections with additional <code> elements to meet the requirement -->
    <section id="JavaScript_and_Java" class="main-section">
      <header>JavaScript and Java</header>
        JavaScript and Java are similar in some ways but fundamentally different in some others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions, and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.
      <!-- Rest of the content for JavaScript and Java -->
      <code>const x = 42;</code>
      <code>let name = 'John';</code>
      <code>function greet() { console.log('Hello!'); }</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>

    <section id="Variables" class="main-section">
        You use variables as symbolic names for values in your application. The names of variables, called identifiers, conform to certain rules.
      <!-- Rest of the content for Variables -->
      <code>let count = 0;</code>
      <code>const PI = 3.14;</code>
      <code>var message = 'Hello, world!';</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>

    <section id="if_else_statement" class="main-section">
      <header>if...else statement</header>
        Use the if statement to execute a statement if a logical condition is true. Use the optional else clause to execute a statement if the condition is false.
      <!-- Rest of the content for if...else statement -->
      <code>let age = 18;</code>
      <code>if (age >= 18) { console.log('You are an adult.'); }</code>
      <code>else { console.log('You are a minor.'); }</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>

    <section id="while_statement" class="main-section">
      <header>while statement</header>
        A while statement executes its statements as long as a specified condition evaluates to true.
      <!-- Rest of the content for while statement -->
      <code>let i = 0;</code>
      <code>while (i < 5) { console.log(i); i++; }</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>

    <section id="Function_declarations" class="main-section">
      <header>Function declarations</header>
        A function definition (also called a function declaration, or function statement) consists of the function keyword, followed by:
        The name of the function.
        A list of arguments to the function, enclosed in parentheses and separated by commas.
        The JavaScript statements that define the function, enclosed in curly brackets, { }.
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
        <li>Item 5</li>
        <li>Item 6</li>
      <code>function greet(name) { return 'Hello, ' + name + '!'; }</code>
      <code>function multiply(a, b) { return a * b; }</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>

    <section id="Reference" class="main-section">
        All the documentation in this page is taken from MDN.
      <!-- Rest of the content for Reference -->
      <code>// This is a comment</code>
      <code>const array = [1, 2, 3];</code>
      <code>// Additional code 1</code>
      <code>// Additional code 2</code>

    // JavaScript for generating IDs for .main-section
    const mainSections = document.querySelectorAll('.main-section');
    mainSections.forEach(section => {
      const firstChildText = section.querySelector('header').textContent;
      const id = firstChildText.trim().replace(/\s+/g, '_');
      section.setAttribute('id', id);

line below,

**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36</code>

**Challenge:** Technical Documentation Page - Build a Technical Documentation Page

**Link to the challenge:**

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.