Tell us what’s happening:
Describe your issue in detail here.
Your code so far
// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0 || b < 0);
return undefined;
// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
console.log(abTest(-2,2));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Return Early Pattern for Functions
Link to the challenge:
Please Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!
Hi there. I think you are asking how to fix this. I haven’t looked back at the assignment, but right away I see that the format of your if statement needs to change.
Your code…
if (a < 0 || b < 0);
return undefined;
This should follow the format of …
if (comparison) { return statement}
So…
if (a < 0 || b < 0) {
return undefined}
I hope this helps
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
1 Like
Ok, its very powerful advise. thank you I appreciate.