2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Use the Conditional (Ternary) Operator
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 Remember to use < a > **`Read-Search-Ask` **</ a >  if you get stuck. Try to pair program  and write your own code 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								## Use the Conditional (Ternary) Operator
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								###  Problem Explanation:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  You need to write a function named `checkEqual` , which checks if the two parameters are equal. 
						 
					
						
							
								
									
										
										
										
											2019-03-03 22:43:12 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  If the parameters are equal, `Equal`  is to be returned else `Not Equal`  should be returned. 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								##  Hint
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Use ternary operator to check for equality.
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-21 18:36:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								>  _try to solve the problem now_
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Spoiler Alert!
  
						 
					
						
							
								
									
										
										
										
											2018-11-21 18:36:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-21 18:36:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								**Solution ahead!**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function checkEqual(a, b) {
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 13:39:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  return a === b ? "Equal" : "Not Equal";
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 15:37:13 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-11-21 18:36:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Code Explanation:
  
						 
					
						
							
								
									
										
										
										
											2018-11-21 18:36:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 05:10:29 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  A function `checkEqual`  is declared, it accepts two parameters in variables `a`  and `b` . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  The `return`  statement would return the value of the evaluated ternary expression. 
						 
					
						
							
								
									
										
										
										
											2019-03-02 13:39:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  The ternary expression checks if `a`  and `b`  are equal or not and returns `Equal`  or `Not Equal`  respectively.