mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): Added an example for Math.abs() (#53498)
Co-authored-by: Krzysztof G. <60067306+gikf@users.noreply.github.com>
This commit is contained in:
+8
-1
@@ -9,7 +9,14 @@ dashedName: step-81
|
||||
|
||||
When the user has a calorie deficit, the `remainingCalories` value will be negative. You don't want to display a negative number in the result string.
|
||||
|
||||
`Math.abs()` is a built-in JavaScript method that will return the absolute value of a number. In your `span` text, wrap your `remainingCalories` reference in `Math.abs()` to ensure that the value is positive.
|
||||
`Math.abs()` is a built-in JavaScript method that will return the absolute value of a number.
|
||||
|
||||
```js
|
||||
const num = -5;
|
||||
Math.abs(num); // 5
|
||||
```
|
||||
|
||||
In your `span` text, wrap your `remainingCalories` reference in `Math.abs()` to ensure that the value is positive.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user