chore: Add missing quotes to Calorie Counter project (#53762)

This commit is contained in:
Ilenia
2024-02-16 21:07:26 +07:00
committed by GitHub
parent dc369b0937
commit 9859eb53f1
8 changed files with 14 additions and 14 deletions
@@ -9,7 +9,7 @@ dashedName: step-14
It is time to start writing the script that makes your form work.
To access an HTML element with a given `id` name, you can use the <dfn>getElementById()</dfn> method. Here's an example of how to use this method:
To access an HTML element with a given `id` name, you can use the <dfn>`getElementById()`</dfn> method. Here's an example of how to use this method:
```html
<h1 id="title">Main title</h1>
@@ -25,7 +25,7 @@ for (let i = 0; i < charArray.length; i++) {
}
```
Within your loop, you need to check if the character in `strArray` at index `i` is not a `+`, `-`, or a space. If it is not, `push` it to the `cleanStrArray`.
Within your loop, you need to check if the character in `strArray` at index `i` is not a `"+"`, `"-"`, or a space (`" "`). If it is not, `push` it to the `cleanStrArray`.
# --hints--
@@ -9,13 +9,13 @@ dashedName: step-53
The `insertAdjacentHtml` method takes two arguments. The first argument is a string that specifies the position of the inserted element. The second argument is a string containing the HTML to be inserted.
For the first argument, pass the string `beforeend` to insert the new element as the last child of `targetInputContainer`.
For the first argument, pass the string `"beforeend"` to insert the new element as the last child of `targetInputContainer`.
For the second argument, pass your `HTMLString` variable.
# --hints--
You should pass the string `beforeend` as the first argument to `insertAdjacentHTML`.
You should pass the string `"beforeend"` as the first argument to `insertAdjacentHTML`.
```js
assert.match(addEntry.toString(), /insertAdjacentHTML\(\s*('|")beforeend\1/);
@@ -25,7 +25,7 @@ button.addEventListener('click', printName);
The `addEventListener` method takes two arguments. The first is the event to listen to. (Ex. `'click'`) The second is the callback function, or the function that runs when the event is triggered.
Call the `.addEventListener()` method on the `addEntryButton`. Pass in the string `click` for the first argument and the `addEntry` function for the second argument.
Call the `.addEventListener()` method on the `addEntryButton`. Pass in the string `"click"` for the first argument and the `addEntry` function for the second argument.
Note that you should not *call* `addEntry`, but pass the variable (or <dfn>function reference</dfn>) directly.
@@ -37,7 +37,7 @@ You should call the `.addEventListener()` method of the `addEntryButton`.
assert.match(code, /addEntryButton\.addEventListener\(/);
```
You should pass `click` as the first argument to the `.addEventListener()` method.
You should pass `"click"` as the first argument to the `.addEventListener()` method.
```js
assert.match(code, /addEntryButton\.addEventListener\(\s*('|")click\1\s*/);
@@ -9,7 +9,7 @@ dashedName: step-61
Browsers have a built in `alert()` function, which you can use to display a pop-up message to the user. The message to display is passed as the argument to the `alert()` function.
Using a template literal, in your `if` block, call the `alert()` function to tell the user `Invalid Input: `, followed by the first value in the `invalidInputMatch` array.
Using a template literal, in your `if` block, call the `alert()` function to tell the user `"Invalid Input: "`, followed by the first value in the `invalidInputMatch` array.
# --hints--
@@ -19,14 +19,14 @@ You should call the `alert()` function in your `if` block.
assert.match(getCaloriesFromInputs.toString(), /if\s*\(\s*invalidInputMatch\s*\)\s*\{\s*alert\(/);
```
You should use a template literal to pass the `Invalid Input: ` message to the `alert()` function.
You should use a template literal to pass the `"Invalid Input: "` message to the `alert()` function.
```js
// because it transforms template literals...
assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: /);
```
You should display the first element of the `invalidInputMatch` array after the `Invalid Input: ` text by using a template literal.
You should display the first element of the `invalidInputMatch` array after the `"Invalid Input: "` text by using a template literal.
```js
assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)/);
@@ -9,7 +9,7 @@ dashedName: step-77
You need to know if the user is in a caloric surplus or deficit. A caloric surplus is when you consume more calories than you burn, and a caloric deficit is when you burn more calories than you consume. Burning as many calories as you consume is called maintenance, and can be thought of as a surplus or deficit of `0`, depending on your goals.
Declare a `surplusOrDeficit` variable. Then use a ternary operator to set `surplusOrDeficit` to the string `Surplus` or `Deficit` depending on whether `remainingCalories` is less than `0`. If it is less than `0`, then `surplusOrDeficit` should be `Surplus`. Otherwise, it should be `Deficit`.
Declare a `surplusOrDeficit` variable. Then use a ternary operator to set `surplusOrDeficit` to the string `"Surplus"` or `"Deficit"` depending on whether `remainingCalories` is less than `0`. If it is less than `0`, then `surplusOrDeficit` should be `"Surplus"`. Otherwise, it should be `"Deficit"`.
# --hints--
@@ -25,13 +25,13 @@ You should have a ternary operator that checks if `remainingCalories` is less `0
assert.match(calculateCalories.toString(), /remainingCalories\s*<\s*0\s*\?/g);
```
Your ternary operator should return the string `Surplus` if `remainingCalories` is less than `0`.
Your ternary operator should return the string `"Surplus"` if `remainingCalories` is less than `0`.
```js
assert.match(calculateCalories.toString(), /remainingCalories\s*<\s*0\s*\?\s*('|")Surplus\1\s*:/g);
```
Your ternary operator should return the string `Deficit` if `remainingCalories` is not less than `0`.
Your ternary operator should return the string `"Deficit"` if `remainingCalories` is not less than `0`.
```js
assert.match(calculateCalories.toString(), /remainingCalories\s*<\s*0\s*\?\s*('|")Surplus\1\s*:\s*('|")Deficit\2/g);
@@ -25,7 +25,7 @@ You should call the `.add()` method on the `classList` property of the `output`
assert.match(clearForm.toString(), /output\.classList\.add/);
```
You should pass `hide` as the argument to the `.add()` method.
You should pass `"hide"` as the argument to the `.add()` method.
```js
assert.match(clearForm.toString(), /output\.classList\.add\(\s*('|")hide\1\s*\)/);
@@ -19,7 +19,7 @@ You should add an event listener to the `clearButton` button.
assert.match(code, /clearButton\s*\.addEventListener\s*\(/);
```
You should pass `click` as the first argument to `.addEventListener()`.
You should pass `"click"` as the first argument to `.addEventListener()`.
```js
assert.match(code, /clearButton\s*\.addEventListener\s*\(\s*('|"|`)click\1\s*/);