Skip to content

Raghad Butaiban#9

Open
rbutaiban wants to merge 1 commit intoJoinCODED:mainfrom
rbutaiban:main
Open

Raghad Butaiban#9
rbutaiban wants to merge 1 commit intoJoinCODED:mainfrom
rbutaiban:main

Conversation

@rbutaiban
Copy link

No description provided.


return -1; // replace -1 with what you see is fit

let NoOfOdd: number = Math.floor(n/2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch out for variable naming. We should always make sure variables start with small letter.

if (n%2 != 0)
return true;
return false; // replace false with what you see is fit
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just return the result of the condition:

function isOdd(n: number): boolean {
  return n%2 !== 0;
}

Also, please use === and !==

return n*2;
else
return n ** 2;
// return -1; // replace -1 with what you see is fit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have reused the isOdd function:

return isOdd(n) ? n ** 2 : n * 2;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants