Tell us what’s happening:
Having trouble understanding/making this lesson :3 can someone give a hint our explanation what to do?
Your code so far
// Setup
function abTest(a, b) {
// Only change code below this line
if (a <= 0) {
return = "undefined";
}
else (b <= 0) {
return = "undefined";
}
// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
// Change values below to test your code
abTest(2,2);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15.
You meant the hint that it is a keyword right? but all i can seem to find is this: https://www.w3schools.com/jsref/jsref_undefined.asp
which looks more like a string. could u elaborate onto what you meant?
Just in general @KittyKora, be careful with mixing up <= and < – always have a think about exactly what you’re trying to compare each time. It’s really easy to make the mistake, and once you’ve made it anf you’ve been looking at the code for a while, it’s often quite hard to debug (everything looks correct at first glance)
Sorry, I can see why you did that, the – was just punctuation in the sentence I wrote: it’s just < 0 (and else if not else, else on its own doesn’t take a condition)
an other thing you missed is that there is a big difference between undefined, which is a reserved word with a specific value, and "undefined" which is just a normal string. You need to return undefined, not "undefined"
Second thing, remember you don’t assign to the return keyword, instead you put to the right of the word what shoukd be returned from the function
if you need to return for example1234 you write return 1234;
No, the syntax is correct but you’ve decided to swap the conditions round for some reason, you did have b < 0 but you’ve decided to make it 0 < b which is the complete opposite.
And it’s
if (condition) {
return something
} else if (condition) {
return something else
}
If you wanted to put them in two blocks as you were trying to do originally