Wsieci
April 7, 2020, 6:44pm
1
function checkSign(num) {
return (num === 0) ? “zero” : (num < 0) ? “negative” : (num > 0) ? “positive”: “”
}
checkSign(10);
At first, it did not work, than I tried the following line: “positive”: “”
Before, I had stopped at: “positive”;
Id like to understand that logic behind it, because the example given was:
function findGreaterOrEqual(a, b) {
return (a === b) ? "a and b are equal" : (a > b) ? "a is greater" : "b is greater";
}
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Every question mark has to have a corresponding colon. Your original code sounds like it didn’t have a colon to match the last question mark. You could have also done it like this:
return (num === 0) ? "zero" : (num < 0) ? "negative" : "positive";
Hope that helps!