# Unit 5 Stage 8 (===)

**URL:** <https://forum.code.org/t/unit-5-stage-8/6533>\
**Category:** Unit and Lesson Discussion\
**Tags:** csp-unit-5, csp-unit-5-lesson-8\
**Created:** [January 20, 2017, 1:18pm UTC](https://forum.code.org/t/unit-5-stage-8/6533 "2017-01-20T13:18:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![baker](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/baker/32/1229_2.png) [@baker](https://forum.code.org/u/baker)\
**Post date:** [January 23, 2017, 3:09pm UTC](https://forum.code.org/t/unit-5-stage-8/6533/3 "2017-01-23T15:09:25Z")

</div>

This double-equal v. triple-equal thing in JavaScript is dastardly for the first time learner because they are unlikely to need or notice the difference between the two.

@anmrobnott is right about the difference. The `==` is said to be “coercive” - it will try its best to figure out what you’re trying to compare. Often this is convenient, especially when user input is involved, because you don’t have to do as much type conversion by hand. The `===` is the strict equality operator you’re probably more familiar with from languages like Java/C/C++ etc.

To help with data type issues, you should know that App Lab has numeric equivalents for operators that typically return strings.

```
prompt("message"); // pop up input message, return user input as string
promptNum("message"); // pop up input message, force user to enter number, return it

getText(id); // get value out of UI element as string
getNumber(id); // attempt to convert value in UI element to numeric type

```

In most cases for this course `==` is fine. If you want the gutter warnings to go away, just make it a `===` and it likely won’t make a difference. One place `===` might bite you is this case where you’re maintaining a variable as a number, but use getText to compare it to value you extract from the UI. e.g.

```
var score = 10;

if( getText('scoreLabel') === score){
   //game over
}

```

In this case if `scoreLabel` happens to have “10” in it, getText returns the literal string “10” which when compared with the number 10 via === will evaluate to false.

Hope this helps

Baker  
CSP Team

---

_[View the full topic](https://forum.code.org/t/unit-5-stage-8/6533)._
