+ 1
"=" and "==" and "===" what is the difference in javascript ???
When I started to apply some of what I learned in javascript I encountered this problem and it is not to differentiate between "=" and "==" and "===" so when we use each of them please ???
2 Answers
+ 1
Ruben Enkaoua thank you very much for answer but in this code, which ones should be used
var age = prompt("please enter your age !!!"),
calculate = prompt("how would you like to calculate your age ??? months or days or
hours or minutes or seconds"),
months = age * 12,
days = age * 365,
hours = days * 24,
minutes = hours * 60,
seconds = minutes * 60;
if (calculate === months) {
alert("your age by months is : " + months);
} else if (calculate = days) {
alert("your age by days is : " + days);
} else if (calculate = hours) {
alert("your age by hours is : " + hours);
} else if (calculate = minutes) {
alert("your age by minutes is : " + minutes);
} else if (calculate = seconds) {
alert("your age by seconds is : " + seconds);
}
i undersand calculate === months or calculate == months or calculate = months
+ 1
so thanks :)