2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Comparison with the Inequality Operator
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Comparison with the Inequality Operator
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-08 23:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Problem explanation:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								· _Add the inequality operator `!=` in the `if` statement so that the function will return "Not equal" when `val` is not equivalent to `99`._ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Hint 1
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The inequality operator (`!=` ) will return `true`  if the first value is not equal to the second one without taking value type into consideration.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								>  _try to solve the problem now_
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Spoiler alert!
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								**Solution ahead!**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Basic code solution:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2019-03-08 23:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Setup
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								function testNotEqual(val) {
							 
						 
					
						
							
								
									
										
										
										
											2019-03-08 23:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if (val != 99) { // Change this line
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    return "Not Equal";
							 
						 
					
						
							
								
									
										
										
										
											2019-03-08 23:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  return "Equal";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-03-08 23:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Change this value to test
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								testNotEqual(10);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								·  Run code at [repl.it ](https://repl.it/@AdrianSkar/Basic-JS-Comparison-with-the-inequality-operator ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Code explanation
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The function first evaluates `if`  the condition `(val != 99)`  evaluates to `true` . If it does, it returns the statement between the curly braces ("Not equal"). If it doesn't, it returns the next `return`  statement outside them ("Equal"). 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Resources
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  ["Inequality operator" - *MDN JavaScript reference* ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Using_the_Equality_Operators#Inequality_(! ))