From 1972f39b6888cebfa15bdabebb0e9ebb12341777 Mon Sep 17 00:00:00 2001 From: SaifullahBijapur <126943764+SaifullahBijapur@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:31:09 +0530 Subject: [PATCH] fix(curriculum): Added an example for Math.abs() (#53498) Co-authored-by: Krzysztof G. <60067306+gikf@users.noreply.github.com> --- .../63c9e769df38c92635c158ba.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e769df38c92635c158ba.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e769df38c92635c158ba.md index 6c13b9849ea..b965bd19f49 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e769df38c92635c158ba.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e769df38c92635c158ba.md @@ -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--