# Basic if/else statements

**URL:** <https://forum.freecodecamp.org/t/basic-if-else-statements/475291>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 25, 2021, 1:09pm UTC](https://forum.freecodecamp.org/t/basic-if-else-statements/475291 "2021-08-25T13:09:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exupnotera](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/exupnotera/32/136162_2.png) [@Exupnotera](https://forum.freecodecamp.org/u/Exupnotera)\
**Post date:** [August 25, 2021, 1:09pm UTC](https://forum.freecodecamp.org/t/basic-if-else-statements/475291/1 "2021-08-25T13:09:49Z")

</div>

Hi can you tell me what is wrong here. I know that this is basic stuff but I am a beginner. I wrote this code :

```auto
let greeting;
let periodOfTheDay = "afternoon";
if (periodOfTheDay = "morning") {greeting = "Good Morning";
}
else if (periodOfTheDay = "afternoon") {greeting = "Good Afternoon" ;
}
else if (periodOfTheDay = "evening") {greeting = "Good Evening" ;
}
else {greeting = "Hello There";
}
console.log (greeting);

```

Now, no matter how I name my period of the day, it always says Good Morning, when I run the project…Can you help me out on what’s wrong?

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [August 25, 2021, 1:17pm UTC](https://forum.freecodecamp.org/t/basic-if-else-statements/475291/2 "2021-08-25T13:17:52Z")

</div>

Are you sure that assignments and comparisons are done in the same way?

> [@Exupnotera](#):
>
> ```auto
> let periodOfTheDay = "afternoon";
> if (periodOfTheDay = "morning") 
> 
> ```

* * *

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:** [February 24, 2022, 1:18am UTC](https://forum.freecodecamp.org/t/basic-if-else-statements/475291/3 "2022-02-24T01:18:40Z")

</div>

Closed on February 24, 2022, 1:18am UTC

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