Sitemap

Member-only story

Javascript Interview Tips

2 min readApr 5, 2020

--

Press enter or click to view image in full size
Photo by Irvan Smith on Unsplash

Difference between == & ===

Both compare equality, but the three equal signs are also checked to make sure both are the same data type.

What is the value of foo?

var foo = 10 + '20';

The value of foo would be a string with the value = “1020”.

What is a terminal application?

A terminal application is a program that runs from the command line/prompt.

Ternary Operator

A ternary operator is a shorthand way to write an if-else statement. In the below code the ternary operators are “?” and “:”. So it’s saying if the condition (isMember in this case) is true, return whatever is after the question mark, else return whatever is after the double colon.

function getFee(isMember) {
return (isMember ? '$2.00' : '$10.00');
}
console.log(getFee(true));
// expected output: "$2.00"
console.log(getFee(false));
// expected output: "$10.00"
console.log(getFee(1));
// expected output: "$2.00"

console.log(getFee(true));
// expected output: “$2.00”

--

--