# Introducing Else Statements (comments)

**URL:** <https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [May 9, 2022, 11:46am UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832 "2022-05-09T11:46:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![favourdylismundi](https://avatars.discourse-cdn.com/v4/letter/f/ecd19e/32.png) [@favourdylismundi](https://forum.freecodecamp.org/u/favourdylismundi)\
**Post date:** [May 9, 2022, 11:46am UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832/1 "2022-05-09T11:46:15Z")

</div>

**Tell us what’s happening:**  
Describe your issue in detail here.  
They said I should not change the code above or below the specified comments. And I don’t know how to do that

```
  **Your code so far**

```

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/introducing-else-statements)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![Cryptic\_X](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cryptic_x/32/258542_2.png) [@Cryptic\_X](https://forum.freecodecamp.org/u/Cryptic_X)\
**Post date:** [May 9, 2022, 11:48am UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832/2 "2022-05-09T11:48:11Z")

</div>

Please post your code.  
It is difficult to help you without the code.

---

<div class="post-metadata">

**Author:** ![favourdylismundi](https://avatars.discourse-cdn.com/v4/letter/f/ecd19e/32.png) [@favourdylismundi](https://forum.freecodecamp.org/u/favourdylismundi)\
**Post date:** [May 9, 2022, 11:51am UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832/3 "2022-05-09T11:51:36Z")

</div>

Oh, Sorry  
This is my code

```auto
function testElse(val) {

  let result = "";

  // Only change code below this line

  if (val > 5) {

    result = "Bigger than 5";

  }

  if (val <= 5) {

    result = "5 or Smaller";

  }

  // Only change code above this line

  return result;

}

testElse(4);

```

---

<div class="post-metadata">

**Author:** ![Cryptic\_X](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cryptic_x/32/258542_2.png) [@Cryptic\_X](https://forum.freecodecamp.org/u/Cryptic_X)\
**Post date:** [May 9, 2022, 12:04pm UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832/4 "2022-05-09T12:04:33Z")

</div>

> [@favourdylismundi](#):
>
> // Only change code below this line
> 
> ```auto
> if (val > 5) {
> result = "Bigger than 5";
> }
> 
> if (val <= 5) {
> result = "5 or Smaller";
> }
> // Only change code above this line
> 
> ```

You are asked to change the code to make the two`'if statements` into `one if-else `statement.

In case you don’t know I’ll show you an example. :

```auto
if (num > 10) {
  return "Bigger than 10";
} 

if (num < 10) {
  return "10 or Less";
}

```

In this there are two if statements. So how would you make it into one if-else statement?

```auto
if (num > 10) {
  return "Bigger than 10";
} else {
  return "10 or Less";
}

```

This is the if-else statement.The second if from the if-if statement is changed into an else.

The if-else statement above says, if a certain variable num is bigger than 10 return “Bigger than 10”, else if this condition is false than return “10 or less”.

Hope you will be able to solve your problem with the help of this example

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 9, 2022, 1:51pm UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832/5 "2022-05-09T13:51:02Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [November 8, 2022, 1:51am UTC](https://forum.freecodecamp.org/t/introducing-else-statements-comments/507832/6 "2022-11-08T01:51:25Z")

</div>

Closed on November 8, 2022, 1:51am UTC

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