Monday, May 10, 2021

Javascript Practice 41: JS Hero - Strict equality

 
Question: 

Write a function equals that checks two values for strict equality.

Example: equals(1, 1) should return true and equals(1, 2) should return false.




Answer: 

function equals (a,b) {

let x = a === b; 

return x
};  


> create a variable x 
> initialize it with a value 
> like this a === b
> the '===' or strict equality operator checks if the values a & b are equal 
> the strict equality operator also checks if the data type of a & b are equal
> we then return the variable 'x'

No comments:

Post a Comment