chore(i18n,learn): processed translations (#50558)

This commit is contained in:
camperbot
2023-05-31 07:00:05 +05:30
committed by GitHub
parent 0fff77d3e0
commit e4f1f14a5a
75 changed files with 340 additions and 340 deletions

View File

@@ -11,31 +11,31 @@ Within your `body`, create a `main` element. Then in that element, create a `sec
# --hints--
You should have a `main` element.
Du solltest ein `main`-Element haben.
```js
assert.exists(document.querySelector('main'));
```
Your `main` element should be within your `body` element.
Dein `main`-Element sollte sich innerhalb deines `body`-Elements befinden.
```js
assert(document.querySelector('main')?.parentElement?.localName === 'body');
```
You should have a `section` element.
Du solltest ein `section`-Element haben.
```js
assert.exists(document.querySelector('section'));
```
Your `section` element should be within your `main` element.
Dein `section`-Element sollte sich innerhalb deines `main`-Elements befinden.
```js
assert(document.querySelector('section')?.parentElement?.localName === 'main');
```
Your `section` element should have the `class` set to `heading`.
Dein `section`-Element sollte die `class` auf `heading` eingestellt haben.
```js
assert(document.querySelector('section')?.classList?.contains('heading'));

View File

@@ -17,55 +17,55 @@ Give your new `img` element a `loading` attribute set to `lazy`.
# --hints--
You should create a `header` element.
Du solltest ein `header`-Element erstellen.
```js
assert.exists(document.querySelector('header'));
```
Your `header` element should be within your `.heading` element.
Dein `header`-Element sollte sich innerhalb deines `.heading`-Elements befinden.
```js
assert(document.querySelector('header')?.parentElement?.className === 'heading');
```
Your `header` element should have the `class` set to `hero`.
Dein `header`-Element sollte die `class` auf `hero` eingestellt haben.
```js
assert(document.querySelector('header')?.className === 'hero');
```
You should create an `img` element.
Du solltest ein `img`-Element erstellen.
```js
assert.exists(document.querySelector('img'));
```
Your `img` element should be within your `header` element.
Dein `img`-Element sollte sich innerhalb deines `header`-Elements befinden.
```js
assert(document.querySelector('img')?.parentElement?.localName === 'header');
```
Your `img` element should have the `src` set to `https://cdn.freecodecamp.org/platform/universal/fcc_meta_1920X1080-indigo.png`.
Dein `img`-Element sollte die `src` auf `https://cdn.freecodecamp.org/platform/universal/fcc_meta_1920X1080-indigo.png` eingerichtet haben.
```js
assert(document.querySelector('img')?.getAttribute('src') === 'https://cdn.freecodecamp.org/platform/universal/fcc_meta_1920X1080-indigo.png');
```
Your `img` element should have the `alt` set to `freecodecamp logo`.
Dein `img`-Element sollte den `alt` auf `freecodecamp logo` eingerichtet haben.
```js
assert(document.querySelector('img')?.getAttribute('alt') === 'freecodecamp logo');
```
Your `img` element should have the `loading` attribute set to `lazy`.
Dein `img`-Element sollte das `loading`-Attribut auf `lazy` eingerichtet haben.
```js
assert(document.querySelector('img')?.getAttribute('loading') === 'lazy');
```
Your `img` element should have the `class` set to `hero-img`.
Dein `img`-Element sollte die `class` auf `hero-img` eingerichtet haben.
```js
assert(document.querySelector('img')?.className === 'hero-img');

View File

@@ -11,17 +11,17 @@ Now that the magazine layout is finished, you need to make it responsive.
Start with a `@media` query for `only screen` with a `max-width` of `720px`. Inside, create an `.image-wrapper` selector and give it a `grid-template-columns` property of `1fr`.
This will collapse the three images into one column on smaller screens.
Dadurch werden die drei Bilder auf kleineren Bildschirmen zu einer einzigen Spalte zusammengefügt.
# --hints--
You should have a new `@media` rule for `only screen and (max-width: 720px)`.
Du solltest eine neue `@media`-Regel für `only screen and (max-width: 720px)` haben.
```js
assert(new __helpers.CSSHelp(document).getCSSRules('media')?.[0]?.media?.mediaText === 'only screen and (max-width: 720px)');
```
Your new `@media` rule should have an `.image-wrapper` selector.
Deine neue `@media`-Regel sollte einen `.image-wrapper`-Selektor enthalten.
```js
assert(new __helpers.CSSHelp(document).getCSSRules('media')?.[0]?.cssRules?.[0]?.selectorText === '.image-wrapper');

View File

@@ -11,7 +11,7 @@ Target the `.face` element with the `right` class, and position it `5%` right of
# --hints--
You should use the `.face.right` selector.
Du solltest den `.face.right`-Selektor verwenden.
```js
assert.match(code, /\.face\.right\s*\{/);

View File

@@ -7,25 +7,25 @@ dashedName: step-32
# --description--
The `strong` element is used to indicate that some text is of strong importance or urgent.
Das `strong`-Element wird verwendet, um anzuzeigen, dass mancher Text von großer Bedeutung oder dringend ist.
In the `figcaption` you just added, indicate that `hate` is of strong importance by wrapping it in a `strong` element.
# --hints--
Your `strong` element should have an opening tag. Opening tags have this syntax: `<elementName>`.
Dein `strong`-Element sollte ein öffnendes Tag haben. Öffnende Tags haben folgende Syntax: `<elementName>`.
```js
assert(document.querySelector('strong'));
```
Your `strong` element should have a closing tag. Closing tags have a `/` just after the `<` character.
Dein `strong`-Element sollte ein schließendes Tag haben. Schließende Tags haben ein `/` direkt nach dem `<` Zeichen.
```js
assert(code.match(/<\/strong\>/));
```
Your `strong` element should surround the word `hate` in the text `Cats hate other cats.` You have either omitted the text or have a typo.
Your `strong` element should surround the word `hate` in the text `Cats hate other cats.` Du hast entweder den Text weggelassen oder einen Tippfehler gemacht.
```js
assert(
@@ -36,7 +36,7 @@ assert(
);
```
The `figcaption`'s text should be `Cats hate other cats.` Check for typos and that the necessary spaces are present around the `strong` element's opening and closing tags.
Der Text von `figcaption` sollte `Cats hate other cats.` sein Check for typos and that the necessary spaces are present around the `strong` element's opening and closing tags.
```js
const secondFigCaption = document.querySelectorAll('figcaption')[1];

View File

@@ -7,13 +7,13 @@ dashedName: step-55
# --description--
You want the `select` element to remain with a white background, but now it is not getting the same `min-height` as the `input` and `textarea` elements.
Du willst, dass das `select`-Element einen weißen Hintergrund beibehält, aber jetzt bekommt es nicht die gleiche `min-height` wie die `input`- und `textarea`-Elemente.
Move the `min-height` property and value so that all three element types have the same `min-height` value, and the `select` element still has a white background.
# --hints--
You should move the `min-height` property and value to the `input, textarea, select` selector.
Du solltest deine `min-height`-Eigenschaft und den Wert in den `input, textarea, select`-Selektor verschieben.
```js
assert.isNotEmpty(new __helpers.CSSHelp(document).getStyle('input, textarea, select')?.minHeight);
@@ -25,7 +25,7 @@ You should give the `input, textarea, select` selector a `min-height` of `2em`.
assert.equal(new __helpers.CSSHelp(document).getStyle('input, textarea, select')?.minHeight, '2em');
```
You should remove the `min-height` declaration from the `input, textarea` selector.
Du solltest die `min-height`-Deklaration aus dem `input, textarea`-Selektor entfernen.
```js
assert.isEmpty(new __helpers.CSSHelp(document).getStyle('input, textarea')?.minHeight);

View File

@@ -11,7 +11,7 @@ Margin is the area outside of the box, and can be used to control the space betw
Here the bottom element has a larger top margin, pushing it further down the page.
Now that you understand the CSS box model, let's get started on the Rothko painting.
Lass uns nun, da du das CSS-Boxmodell verstehst, mit dem Rothko-Bild beginnen.
Remove the `<img>` element.

View File

@@ -9,11 +9,11 @@ dashedName: step-7
Before you can start styling the `div` you added, you need to link your CSS to your HTML.
Add a `link` element to link your `styles.css` file. Set the `href` to `styles.css`, and remember to set the `rel` attribute to `stylesheet`.
Add a `link` element to link your `styles.css` file. Setze den `href` auf `styles.css` und denke daran, das `rel`-Attribut auf `stylesheet` zu setzen.
# --hints--
Your code should have a `link` element.
Dein Code sollte ein `link`-Element enthalten.
```js
assert(/<link/.test(code))

View File

@@ -29,7 +29,7 @@ Abbiamo definito la variabile `food` nella testa del loop e questa variabile è
# --instructions--
Abbiamo definito una funzione `countOnline` che accetta un argomento, `allUsers`. Use a <dfn>for...in</dfn> statement inside this function to loop through the `allUsers` object and return the number of users whose `online` property is set to `true`. Un esempio di oggetto che potrebbe essere passato a `countOnline` è mostrato di sotto. Ogni utente avrà una proprietà `online` con un valore impostato su `true` o `false`.
Abbiamo definito una funzione `countOnline` che accetta un argomento, `allUsers`. Usa un'istruzione <dfn>for...in</dfn> all'interno di questa funzione per iterare sull'oggetto `allUsers` e restituire il numero di utenti la cui proprietà `online` è impostata su `true`. Un esempio di oggetto che potrebbe essere passato a `countOnline` è mostrato di sotto. Ogni utente avrà una proprietà `online` con un valore impostato su `true` o `false`.
```js
{

View File

@@ -51,7 +51,7 @@ Il tuo codice dovrebbe utilizzare la notazione a punti e parentesi per accedere
assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(code));
```
`gloveBoxContents` should still be declared with `const`.
`gloveBoxContents` dovrebbe ancora essere dichiarata con `const`.
```js
assert.match(code, /const\s+gloveBoxContents\s*=/)

View File

@@ -18,7 +18,7 @@ Font Awesome è una comoda libreria di icone. Queste icone possono essere font w
Usa Font Awesome per aggiungere un'icona `info-circle` al tuo pulsante info e un'icona `trash` al tuo pulsante di eliminazione.
**Note:** You can use either `i` or `span` elements to complete this challenge.
**Nota:** puoi usare elementi `i` o `span` per completare questa sfida.
# --hints--

View File

@@ -9,7 +9,7 @@ dashedName: step-28
Potresti notare che c'è ancora un piccolo bordo nella parte inferiore dell'elemento `.large`. Per rimuoverlo, assegna al selettore `.large, .medium` una proprietà `border` con il valore `0`.
Note: the `medium`(medium) class will be utilized later for the thinner bars of the nutrition label.
Nota: la classe `medium` (media) sarà utilizzata in seguito per le barre più sottili dell'etichetta nutrizionale.
# --hints--

View File

@@ -7,7 +7,7 @@ dashedName: step-11
# --description--
Now it's time to start building the HTML for the page with your destructured data. You can do this with a combination of the compound assignment operator (`+=`) and the `innerHTML` property.
Ora è il momento di iniziare a creare l'HTML per la pagina con i dati destrutturati. Puoi farlo con una combinazione dell'operatore di assegnazione composta (`+=`) e la proprietà `innerHTML`.
All'interno della funzione callback, usa l'operatore di assegnazione composta per aggiungere un template literal vuoto all'`innerHTML` di `authorContainer`.

View File

@@ -11,7 +11,7 @@ Crea una funzione `isSpam` usando la parola chiave `const` e la sintassi freccia
# --hints--
You should use `const` to declare an `isSpam` variable.
Dovresti usare `const` per dichiarare la variabile `isSpam`.
```js
assert.match(code, /const\s+isSpam\s*=/);

View File

@@ -7,37 +7,37 @@ dashedName: step-13
# --description--
Finally, after your `p` elements, create a `button` element. Give it an `id` set to the value of the `id` variable, a `class` of `btn add-to-cart-btn`, and use `Add to cart` for the text.
Por fim, após os elementos `p`, crie um elemento `button`. Dê a ele um `id` definido com o valor da variável `id`, uma `class` `btn add-to-cart-btn` e use `Add to cart` como texto.
# --hints--
You should create a `button` element.
Você deve criar um elemento `button`.
```js
assert.equal(document.querySelectorAll('.dessert-card button')?.length, 12);
```
Your `button` element should come after your `p` elements.
O elemento `button` deve vir depois do elemento `p`.
```js
assert.equal(document.querySelector('.dessert-card button')?.previousElementSibling?.tagName, 'P');
assert.isNull(document.querySelector('.dessert-card button')?.nextElementSibling);
```
Your `button` element should have an `id` set to the value of the `id` variable.
O elemento `button` deve ter um `id` definido como o valor da variável `id`.
```js
assert.equal(document.querySelector('.dessert-card button')?.id, '1');
```
Your `button` element should have a `class` of `btn add-to-cart-btn`.
O elemento `button` deve ter uma `class` definida como `btn add-to-cart-btn`.
```js
assert.include(document.querySelector('.dessert-card button')?.className, 'btn');
assert.include(document.querySelector('.dessert-card button')?.className, 'add-to-cart-btn');
```
Your `button` element should have the text `Add to cart`.
O elemento `button` dever ter o texto `Add to cart`.
```js
assert.equal(document.querySelector('.dessert-card button')?.textContent?.trim(), 'Add to cart');

View File

@@ -7,31 +7,31 @@ dashedName: step-14
# --description--
You are already familiar with an HTML `class`, but JavaScript also has a <dfn>class</dfn>. In JavaScript, a class is like a blueprint for creating objects. It allows you to define a set of properties and methods, and instantiate (or create) new objects with those properties and methods.
Você já está familiarizado com a `class` do HTML, mas o JavaScript também tem uma <dfn>classe</dfn>. Em JavaScript, uma classe é como um diagrama para a criação de objetos. Ela permite que você defina um conjunto de propriedades e métodos, além de instanciar (ou criar) objetos com essas propriedades e métodos.
The `class` keyword is used to declare a class. Here is an example of declaring a `Computer` class:
A palavra-chave `class` é usada para declarar uma classe. Aqui está um exemplo de como declarar uma classe `Computer`:
```js
class Computer {};
```
Declare a `ShoppingCart` class.
Declare uma classe `ShoppingCart`.
# --hints--
You should declare a `ShoppingCart` variable.
Você deve declarar uma variável `ShoppingCart`.
```js
assert.match(code, /ShoppingCart/);
```
You should use the `class` keyword to declare a `ShoppingCart` class.
Você deve usar a palavra-chave `class` para declarar a classe `ShoppingCart`.
```js
assert.match(code, /class\s+ShoppingCart\s*/);
```
Your `ShoppingCart` class should be empty.
A classe `ShoppingCart` deve estar vazia.
```js
assert.match(code, /class\s+ShoppingCart\s*\{\s*\}/);

View File

@@ -7,7 +7,7 @@ dashedName: step-15
# --description--
Classes have a special `constructor` method, which is called when a new instance of the class is created. The `constructor` method is a great place to initialize properties of the class. Here is an example of a class with a `constructor` method:
As classes têm um método especial chamado `constructor`, que é usado quando uma instância da classe é criada. O método `constructor` é um ótimo lugar para inicializar propriedades da classe. Aqui está um exemplo de uma classe com um método `constructor`:
```js
class Computer {
@@ -16,17 +16,17 @@ class Computer {
}
```
Add an empty `constructor` method to the `ShoppingCart` class.
Adiciona um método `constructor` vazio à classe `ShoppingCart`.
# --hints--
You should add a `constructor` method to the `ShoppingCart` class.
Você deve adicionar um método `constructor` à classe `ShoppingCart`.
```js
assert.match(code, /class\s+ShoppingCart\s*\{\s*constructor\(\s*\)\s*/)
```
Your `constructor` method should be empty.
O método `constructor` deve estar vazio.
```js
assert.match(code, /class\s+ShoppingCart\s*\{\s*constructor\(\s*\)\s*\{\s*\}\s*\}/)

View File

@@ -7,7 +7,7 @@ dashedName: step-16
# --description--
The `this` keyword in JavaScript is used to refer to the current object. Depending on where `this` is used, what it references changes. In the case of a class, it refers to the instance of the object being constructed. You can use the `this` keyword to set the properties of the object being instantiated. Aqui está um exemplo:
A palavra-chave `this` em JavaScript é usada para se referir ao objeto atual. Dependendo do local onde `this` é usado, a referência que ele tem muda. No caso de uma classe, ele se refere à instância do objeto sendo construído. Você pode usar a palavra-chave `this` para definir as propriedades do objeto que está sendo instanciado. Aqui está um exemplo:
```js
class Computer {
@@ -17,11 +17,11 @@ class Computer {
}
```
In your constructor, use the `this` keyword to set the `items` property to an empty array. Also, set the `total` property to `0`, and the `taxRate` property to `8.25`.
No construtor, use a palavra-chave `this` para definir a propriedade `items` como um array vazio. Além disso, defina a propriedade `total` como `0` e a propriedade `taxRate` como `8.25`.
# --hints--
You should use the `this` keyword to set the `items` property of your class to an empty array.
Você deve usar a palavra-chave `this` para definir a propriedade `items` como um array vazio.
```js
assert.match(code, /this\.items/);
@@ -30,7 +30,7 @@ assert.isArray(cart.items);
assert.isEmpty(cart.items);
```
You should use the `this` keyword to set the `total` property of your class to `0`.
Você deve usar a palavra-chave `this` para definir a propriedade `total` como `0`.
```js
assert.match(code, /this\.total/);
@@ -38,7 +38,7 @@ const cart = new ShoppingCart();
assert.equal(cart.total, 0);
```
You should use the `this` keyword to set the `taxRate` property of your class to `8.25`.
Você deve usar a palavra-chave `this` para definir a propriedade `taxRate` como `8.25`.
```js
assert.match(code, /this\.taxRate/);

View File

@@ -7,7 +7,7 @@ dashedName: step-17
# --description--
Your `ShoppingCart` class needs the ability to add items. Create an empty `addItem` method, which takes two parameters: `id` and `products`. Creating a method might look like this:
A classe `ShoppingCart` precisa ter a capacidade de adicionar itens. Crie um método `addItem` vazio, que recebe dois parâmetros: `id` e `products`. Criar um método terá esta aparência:
```js
class Computer {
@@ -21,25 +21,25 @@ class Computer {
}
```
The first parameter, `id`, is the `id` of the product the user has added to their cart. The second parameter, `products`, is an array of product objects. By using a parameter instead of directly referencing your existing `products` array, this method will be more flexible if you wanted to add additional product lists in the future.
O primeiro parâmetro, `id`, é o `id` do produto que o usuário adicionou ao carrinho. O segundo parâmetro, `products`, é um array de objetos do produto. Usando um parâmetro em vez de fazer referência direta ao array `products` existente, este método será mais flexível se você quiser adicionar outras listas de produtos no futuro.
# --hints--
Your `ShoppingCart` class should have an `addItem` method.
A classe `ShoppingCart` deve ter o método `addItem`.
```js
const cart = new ShoppingCart();
assert.isFunction(cart.addItem);
```
Your `addItem` method should take two parameters: `id` and `products`.
O método `addItem` deve receber dois parâmetros: `id` e `products`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /\(\s*id\s*,\s*products\s*\)/);
```
Your `addItem` method should be empty.
O método `addItem` deve estar vazio.
```js
const cart = new ShoppingCart();

View File

@@ -7,48 +7,48 @@ dashedName: step-18
# --description--
You need to find the product that the user is adding to the cart. Remember that arrays have a `.find()` method. In your `addItem` function, declare a `product` variable, and assign it the value of calling the `.find()` method on the `products` array.
Você precisa encontrar o produto que o usuário está adicionando ao carrinho. Lembre-se de que arrays têm um método `.find()`. Na função `addItem`, declare uma variável `product` e atribua a ela o valor da chamada do método `.find()` no array `products`.
For the callback to `.find()`, pass a function that takes a single parameter `item`, and returns whether the `id` property of `item` is strictly equal to the `id` parameter passed to `addItem`.
Para a função de callback de `.find()`, passe uma função que receba um único parâmetro `item` e retorne se a propriedade `id` do `item` é estritamente igual ao parâmetro `id` passado para `addItem`.
# --hints--
You should declare a `product` variable in your `addItem` function.
Você deve declarar uma variável `product` na função `addItem`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /product\s*=/);
```
You should call the `.find()` method on your `products` array.
Você deve chamar o método `.find()` do array `products`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /products\.find\(/);
```
You should pass a callback function to the `.find()` method.
Você deve passar uma função de callback para o método `.find()`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /products\.find\(\s*function\s*\(/);
```
The callback function should take a single parameter.
A função de callback deve receber um único parâmetro.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /products\.find\(\s*function\s*\(\s*item\s*\)/);
```
The callback function should return whether the `id` property of `item` is strictly equal to the `id` parameter passed to `addItem`.
A função de callback deve retornar se a propriedade `id` do `item` é estritamente igual ao parâmetro `id` passado para `addItem`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /products\.find\(\s*function\s*\(\s*item\s*\)\s*\{\s*return\s+item\.id\s*===\s*id\s*;?\s*\}/);
```
You should assign the value of the `.find()` method to the `product` variable.
Você deve atribuir o valor do método `.find()` à variável `product`.
```js
const cart = new ShoppingCart();

View File

@@ -7,25 +7,25 @@ dashedName: step-19
# --description--
Use `const` and destructuring to extract `name` and `price` variables from `product`.
Use `const` e a desestruturação para extrair as variáveis `name` e `price` de `product`.
# --hints--
You should use destructuring to get the `name` and `price` variables.
Você deve usar a desestruturação para obter as variáveis `name` e `price`.
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /\{\s*name\s*,\s*price\s*\}/);
```
You should use `const` to declare the `name` and `price` variables.
Você deve usar `const` para declarar as variáveis `name` e `price`.
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /const\s*\{\s*name\s*,\s*price\s*\}/);
```
You should use destructuring to get the `name` and `price` variables from `product`.
Você deve usar a desestruturação para extrair as variáveis `name` e `price` de `product`.
```js
const afterAdd = code.split("addItem")[1];

View File

@@ -7,25 +7,25 @@ dashedName: step-20
# --description--
Now you need to push the `product` into the cart's `items` array. Remember to use the `this` keyword.
Agora, você precisa inserir `product` no array `items` do carrinho. Lembre-se de usar a palavra chave `this`.
# --hints--
You should call the `push` method on the `items` array.
Você deve usar o método `push` no array `items`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /items\.push\(/);
```
Remember you need to use the `this` keyword to access the `items` array.
Lembre-se de que você precisa usar a palavra-chave `this` para acessar o array `items`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /this\.items\.push\(/);
```
You should `push` the `product` variable to the `items` array.
Você deve usar `push` para inserir a variável `product` no array `items`.
```js
const cart = new ShoppingCart();

View File

@@ -7,25 +7,25 @@ dashedName: step-21
# --description--
You now need a total count of each product that the user has in the cart. Declare a `totalCountPerProduct` variable, and assign it an empty object.
Agora, você precisa de uma contagem total de cada produto que o usuário tem no carrinho. Declare uma variável `totalCountPerProduct` e atribua a ela um objeto vazio.
# --hints--
You should declare a `totalCountPerProduct` variable in your `addItem` function.
Você deve declarar uma variável `totalCountPerProduct` na função `addItem`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /totalCountPerProduct\s*=/);
```
You should use `const` to declare `totalCountPerProduct`.
Você deve usar `const` para declarar `totalCountPerProduct`.
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /const\s+totalCountPerProduct\s*=/);
```
You should assign an empty object to `totalCountPerProduct`.
Você deve atribuir um objeto vazio a `totalCountPerProduct`.
```js
const afterAdd = code.split("addItem")[1];

View File

@@ -7,39 +7,39 @@ dashedName: step-22
# --description--
Use the `.forEach()` method to loop through the `items` array. Pass an empty callback function that takes a single parameter `dessert`.
Use o método `.forEach()` para percorrer o array `items`. Passe uma função de callback vazia que recebe um único parâmetro `dessert`.
# --hints--
You should use the `.forEach()` method on your `items` array.
Você deve usar o método `.forEach()` do array `items`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /items\.forEach\(/);
```
Remember to use the `this` keyword to access the `items` array.
Lembre-se de usar a palavra-chave `this` para acessar o array `items`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /this\.items\.forEach\(/);
```
You should pass a callback function to the `.forEach()` method.
Você deve passar uma função de callback para o método `.forEach()`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /this\.items\.forEach\(\s*function\s*\(/);
```
Your callback function should take a single parameter.
A função de callback deve receber um único parâmetro.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /this\.items\.forEach\(\s*function\s*\(\s*dessert\s*\)/);
```
Your callback function should be empty.
A função de callback deve estar vazia.
```js
const cart = new ShoppingCart();

View File

@@ -7,32 +7,32 @@ dashedName: step-23
# --description--
In your `forEach` callback, you need to update the `totalCountPerProduct` object. Using the `id` of the current `dessert` as your property, update the value of the property to be the current value plus one. Do not use the addition assignment operator for this.
Na função de callback de `forEach`, você precisa atualizar o objeto `totalCountPerProduct`. Usando o `id` da `dessert` (sobremesa) atual como sua propriedade, atualize o valor da propriedade para que seja o valor atual mais um. Não use o operador de atribuição de adição para isso.
# --hints--
You should use dot notation to access the `id` property of `dessert`.
Você deve usar a notação de ponto para acessar a propriedade `id` de `dessert`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /dessert\.id/);
```
You should use bracket notation to access the property of `totalCountPerProduct` that corresponds to `dessert.id`.
Você deve usar a notação de colchete para acessar a propriedade de `totalCountPerProduct` que corresponde a `dessert.id`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /totalCountPerProduct\[\s*dessert\.id\s*\]/);
```
You should use the assignment operator to update the value of the property of `totalCountPerProduct` that corresponds to `dessert.id`.
Você deve usar o operador de atribuição para atualizar o valor da propriedade de `totalCountPerProduct` que corresponde a `dessert.id`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /totalCountPerProduct\[\s*dessert\.id\s*\]\s*=/);
```
You should update the value of `totalCountPerProduct` to be the current value plus one.
Você deve atualizar o valor de `totalCountPerProduct` para que seja o valor atual mais um.
```js
const cart = new ShoppingCart();

View File

@@ -7,34 +7,34 @@ dashedName: step-24
# --description--
You now have a small bug. When you try to access a property of an object and the property doesn't exist, you get `undefined`. This means if the dessert isn't already present in the `totalCountPerProduct` object, you end up trying to add `1` to `undefined`, which results in `NaN`.
Agora, você tem um pequeno erro. Se você tentar acessar uma propriedade de um objeto e se a propriedade não existe, você obtém `undefined`. Isto significa que, se a sobremesa já não está presente no objeto `totalCountPerProduct`, você acaba tentando adicionar `1` a `undefined`, o que resulta em `NaN`.
To fix this, you can use the `||` operator to set the value to `0` if it doesn't exist. Wrap your right-hand `totalCountPerProduct[data.id]` in parentheses, and add `|| 0` to the end of the expression.
Para consertar isso, você pode usar o operador `||` para definir o valor como `0`, se ele não existir. Envolva o lado direito de `totalCountPerProduct[data.id]` em parênteses e adicione `|| 0` ao final da expressão.
# --hints--
You should wrap your right-hand `totalCountPerProduct[data.id]` in parentheses.
Você deve envolver o lado direito de `totalCountPerProduct[data.id]` em parênteses.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /totalCountPerProduct\[\s*dessert\.id\s*\]\s*=\s*\(\s*totalCountPerProduct\[\s*dessert\.id\s*\]/);
```
You should use the `||` operator.
Você deve usar o operador `||`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /totalCountPerProduct\[\s*dessert\.id\s*\]\s*=\s*\(\s*totalCountPerProduct\[\s*dessert\.id\s*\]\s*\|\|\s*/);
```
You should use `0` as your fallback value.
Você deve usar `0` como valor de fallback.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /totalCountPerProduct\[\s*dessert\.id\s*\]\s*=\s*\(\s*totalCountPerProduct\[\s*dessert\.id\s*\]\s*\|\|\s*0\s*\)/);
```
You should still add `1` to the value.
Você ainda deve adicionar `1` ao valor.
```js
const cart = new ShoppingCart();

View File

@@ -7,25 +7,25 @@ dashedName: step-25
# --description--
Now you need to get prepared to update the display with the new product the user added. Declare a `currentProductCount` variable, and assign it the value of the `totalCountPerProduct` object's property matching the `id` of `product`.
Agora, você precisa se preparar para atualizar a tela com o novo produto que o usuário adicionou. Declare uma variável `currentProductCount` e atribua a ela o valor da propriedade do objeto `totalCountPerProduct` que corresponde ao `id` de `product`.
# --hints--
You should declare a `currentProductCount` variable in your `addItem` function.
Você deve declarar uma variável `currentProductCount` na função `addItem`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /currentProductCount\s*=/);
```
You should use `const` to declare `currentProductCount`.
Você deve usar `const` para declarar `currentProductCount`.
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /const\s+currentProductCount\s*=/);
```
You should assign the value of `totalCountPerProduct[product.id]` to `currentProductCount`.
Você deve atribuir o valor de `totalCountPerProduct[product.id]` como `currentProductCount`.
```js
const cart = new ShoppingCart();

View File

@@ -7,43 +7,43 @@ dashedName: step-26
# --description--
You haven't written the code to generate the HTML yet, but if a product has already been added to the user's cart then there will be a matching element which you'll need.
Você ainda não escreveu o código para gerar o HTML, mas, se um produto já foi adicionado ao carrinho do usuário, haverá um elemento correspondente do qual você precisará.
Use `.getElementById()` to get the matching element - you'll be setting the `id` value to `product-count-for-id${product.id}`, so use a template literal to query that value.
Use `.getElementById()` para obter o elemento correspondente. Você definirá o valor de `id` como `product-count-for-id${product.id}`. Então, use um template literal para consultar esse valor.
Assign your query to a `currentProductCountSpan` variable.
Atribua a consulta a uma variável `currentProductCountSpan`.
# --hints--
You should declare a `currentProductCountSpan` variable.
Você deve declarar uma variável `currentProductCountSpan`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /currentProductCountSpan\s*=/);
```
You should use `const` to declare `currentProductCountSpan`.
Você deve usar `const` para declarar `currentProductCountSpan`.
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /const\s+currentProductCountSpan\s*=/);
```
You should use `document.getElementById()` to get the matching element.
Você deve usar `document.getElementById()` para obter o elemento correspondente.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /document\.getElementById\(/);
```
You should use a template literal to query the `id` value.
Você deve usar um template literal para consultar o valor de `id`.
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /document\.getElementById\(\s*`product-count-for-id\$\{(product\.)?id\}`\s*\)/);
```
You should assign the value of `document.getElementById()` to `currentProductCountSpan`.
Você deve atribuir o valor de `document.getElementById()` a `currentProductCountSpan`.
```js
const cart = new ShoppingCart();

View File

@@ -7,32 +7,32 @@ dashedName: step-27
# --description--
The behaviour of the `addItem` method needs to change if the product is already in the cart or not. Create a ternary that checks if the current product is already in the cart. Use `undefined` for both the truthy and falsy expressions to avoid a syntax error.
O comportamento do método `addItem` precisa mudar conforme o produto estiver no carrinho ou não. Crie um operador ternário que verifique se o produto atual já está no carrinho. Use `undefined` para expressões verdadeiras e falsas para evitar um erro de sintaxe.
# --hints--
You should check if `currentProductCount` is greater than `1`.
Você deve verificar se `currentProductCount` é maior que `1`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /currentProductCount\s*>\s*1/);
```
You should use a ternary operator with your `currentProductCount > 1` condition.
Você deve usar um operador ternário com a condição `currentProductCount > 1`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /currentProductCount\s*>\s*1\s*\?/);
```
You should use `undefined` as the truthy expression.
Você deve usar `undefined` como a expressão verdadeira.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /currentProductCount\s*>\s*1\s*\?\s*undefined/);
```
You should use `undefined` as the falsy expression.
Você deve usar `undefined` como a expressão falsa.
```js
const cart = new ShoppingCart();

View File

@@ -7,25 +7,25 @@ dashedName: step-28
# --description--
For your truthy expression, removing the `undefined`, you need to update the `textContent` of the `currentProductCountSpan` to be the `currentProductCount` followed by an `x`. Use a template literal to do so.
Para a expressão verdadeira, remova o `undefined`. Você precisa atualizar o `textContent` de `currentProductCountSpan` para que seja `currentProductCount` seguido por um `x`. Use um template literal para fazer isso.
# --hints--
You should remove the `undefined` from your truthy expression.
Você deve remover `undefined` da expressão verdadeira.
```js
const cart = new ShoppingCart();
assert.notMatch(cart.addItem.toString(), /currentProductCount\s*>\s*1\s*\?\s*undefined/);
```
You should access the `textContent` property of `currentProductCountSpan`.
Você deve acessar a propriedade `textContent` de `currentProductCountSpan`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /currentProductCount\s*>\s*1\s*\?\s*currentProductCountSpan\.textContent/);
```
You should use template literal syntax to update the `textContent` to be `${currentProductCount}x`.
Você deve usar a sintaxe de template literals para atualizar `textContent` para que seja igual a `${currentProductCount}x`.
```js
const afterAdd = code.split("addItem")[1];

View File

@@ -7,31 +7,31 @@ dashedName: step-29
# --description--
For your falsy expression, you'll need to add new HTML to your `productsContainer`. Start by removing the `undefined`, then use the addition assignment operator and template literal syntax to add a `div` with the `class` set to `product` and the `id` set to `dessert${id}` to the `innerHTML` property of the `productsContainer`.
Para a expressão falsa, você precisará adicionar um novo HTML a `productsContainer`. Comece removendo o `undefined`. Em seguida, use o operador da atribuição de adição e a sintaxe das template literals para adicionar uma `div` com a `class` definida como `product` e o `id` definido como `dessert${id}` para a propriedade `innerHTML` de `productsContainer`.
# --hints--
You should remove the `undefined` from your falsy expression.
Você deve remover `undefined` da expressão falsa.
```js
const cart = new ShoppingCart();
assert.notMatch(cart.addItem.toString(), /undefined/);
```
You should use the addition assignment operator to add HTML to the `productsContainer`. Remember that HTML goes in the `innerHTML` property.
Você deve usar o operador de atribuição de adição para adicionar HTML a `productsContainer`. Lembre-se de que o HTML vai na propriedade `innerHTML`.
```js
const cart = new ShoppingCart();
assert.match(cart.addItem.toString(), /productsContainer\.innerHTML\s*\+=\s*/);
```
You should use template literal syntax to add HTML to the `productsContainer`.
Você deve usar a sintace de template literals para adicionar HTML a `productsContainer`.
```js
assert.match(code, /productsContainer\.innerHTML\s*\+=\s*`/);
```
You should add a `div` to the `productsContainer`.
Você deve adicionar uma `div` a `productsContainer`.
```js
const cart = new ShoppingCart();
@@ -39,7 +39,7 @@ cart.addItem(1, products);
assert.equal(productsContainer.children?.[0]?.tagName, "DIV");
```
Your `div` should have the `class` set to `product`.
A `div` deve ter a `class` definida como `product`.
```js
const cart = new ShoppingCart();
@@ -47,7 +47,7 @@ cart.addItem(1, products);
assert.equal(productsContainer.children?.[0]?.className, "product");
```
Your `div` should have the `id` set to `dessert${id}`.
A `div` deve ter o `id` definido como `dessert${id}`.
```js
const cart = new ShoppingCart();

View File

@@ -7,11 +7,11 @@ dashedName: step-30
# --description--
Inside your `div`, add two `p` elements. Set the text of the second `p` element to be the value of the `price` variable.
Dentro da `div`, adicione dois elementos `p`. Defina o texto do segundo elemento `p` como o valor da variável `price`.
# --hints--
You should add two `p` elements inside your `div` element.
Você deve adicionar dois elementos `p` dentro do elemento `div`.
```js
const cart = new ShoppingCart();
@@ -22,7 +22,7 @@ assert.equal(div?.children[0].tagName, 'P');
assert.equal(div?.children[1].tagName, 'P');
```
Your second `p` element should have the text of the `price` variable.
O segundo elemento `p` deve conter o texto da variável `price`.
```js
const cart = new ShoppingCart();

View File

@@ -7,11 +7,11 @@ dashedName: step-31
# --description--
In your first `p` element, add a `span` element. Give the `span` a class of `product-count` and an `id` of `product-count-for-id${id}`. Then, after the span, give your `p` element the text of the `name` variable.
No primeiro elemento `p`, adicione um elemento `span`. Dê ao `span` a classe `product-count` e um `id` de `product-count-for-id${id}`. Então, após o span, dê ao elemento `p` o texto da variável `name`.
# --hints--
Your first `p` element should have a `span` element.
O primeiro elemento `p` deve ter um elemento `span`.
```js
const cart = new ShoppingCart();
@@ -22,7 +22,7 @@ assert.equal(p.children.length, 1);
assert.equal(p.children[0].tagName, 'SPAN');
```
Your `span` element should have a `class` of `product-count`.
O elemento `span` deve ter uma `class` definida como `product-count`.
```js
const cart = new ShoppingCart();
@@ -32,7 +32,7 @@ const p = div.querySelector('p');
assert.equal(p.children[0].className, 'product-count');
```
Your `span` element should have an `id` of `product-count-for-id${id}`.
O elemento `span` deve ter um `id` definido como `product-count-for-id${id}`.
```js
const cart = new ShoppingCart();
@@ -42,7 +42,7 @@ const p = div.querySelector('p');
assert.equal(p.children[0].id, 'product-count-for-id1');
```
Your first `p` element should have the text of the `name` variable. This should be outside the span.
O primeiro elemento `p` deve ter o texto da variável `name`. Ele deve estar fora do span.
```js
const cart = new ShoppingCart();

View File

@@ -7,29 +7,29 @@ dashedName: step-32
# --description--
There is still more functionality that your `ShoppingCart` class needs, but first you need to be able to test the code you have currently written. You'll need to <dfn>instantiate</dfn> a new `ShoppingCart` object and assign it to a variable. Here is an example of instantiating the `Computer` class from earlier examples:
O `ShoppingCart` ainda precisa de mais funcionalidades, mas, primeiro, você precisa ser capaz de testar o código que escreveu até o momento. Você precisará <dfn>instanciar</dfn> um novo objeto `ShoppingCart` e atribuí-lo a uma variável. Aqui está um exemplo de como instanciar a classe `Computer` dos exemplos anteriores:
```js
const myComputer = new Computer();
```
Declare a `cart` variable, and assign it a new `ShoppingCart` object. Note the use of the `new` keyword when instantiating the object.
Declare uma variável `cart` e atribua a ela um novo objeto `ShoppingCart`. Observe o uso da palavra-chave `new` ao instanciar o objeto.
# --hints--
You should use `const` to declare a `cart` variable.
Você deve usar `const` para declarar uma variável `cart`.
```js
assert.match(code, /const\s+cart\s*=/);
```
You should use the `new` keyword to instantiate a new `ShoppingCart` object.
Você deve usar a palavra-chave `new` para instanciar o novo objeto `ShoppingCart`.
```js
assert.match(code, /new\s+ShoppingCart\s*\(\s*\)/);
```
You should assign your new `ShoppingCart` object to the `cart` variable.
Você deve atribuir o novo objeto `ShoppingCart` à variável `cart`.
```js
assert.isTrue(cart instanceof ShoppingCart);

View File

@@ -7,29 +7,29 @@ dashedName: step-33
# --description--
You need to get all of the `Add to cart` buttons that you added to the DOM earlier. Declare an `addToCartBtns` variable, and assign it the value of calling the `getElementsByClassName()` method on the `document` object, passing in the string `add-to-cart-btn`.
Você precisa obter todos os botões `Add to cart` que você adicionou anteriormente ao DOM. Declare uma variável `addToCartBtns` e atribua a ela o valor da chamada do método `getElementsByClassName()` no objeto `document`, passando a string `add-to-cart-btn`.
# --hints--
You should use `const` to declare your `addToCartBtns` variable.
Você deve usar `const` para declarar uma variável `addToCartBtns`.
```js
assert.match(code, /const\s+addToCartBtns\s*=/);
```
You should call the `getElementsByClassName()` method on the `document` object.
Você deve chamar o método `getElementsByClassName()` no objeto `document`.
```js
assert.match(code, /document\s*\.\s*getElementsByClassName\s*\(/);
```
You should pass the string `add-to-cart-btn` to the `getElementsByClassName()` method.
Você deve passar a string `add-to-cart-btn` para o método `getElementsByClassName()`.
```js
assert.match(code, /document\s*\.\s*getElementsByClassName\s*\(\s*('|"|`)add-to-cart-btn\1\s*\)/);
```
You should assign the value returned by the `getElementsByClassName()` method to the `addToCartBtns` variable.
Você deve atribuir o valor retornado pelo método `getElementsByClassName()` à variável `addToCartBtns`.
```js
assert.deepEqual(addToCartBtns, document.getElementsByClassName('add-to-cart-btn'));

View File

@@ -7,31 +7,31 @@ dashedName: step-34
# --description--
You need to iterate through the buttons in your `addToCartBtns` variable. However, `.getElementsByClassName()` returns a Collection, which does not have a `forEach` method.
Você precisa iterar pelos botões da variável `addToCartBtns`. No entanto, `.getElementsByClassName()` retorna uma coleção, que não tem um método `forEach`.
Use the spread operator on the `addToCartBtns` variable to convert it into an array. Then, use the `forEach` method to iterate through the array. Do not pass a callback function yet.
Use o operador spread na variável `addToCartBtns` para convertê-la em um array. Você deve usar o método `forEach` para percorrer o array. Não passe uma função de callback ainda.
# --hints--
You should use the spread operator on the `addToCartBtns` variable.
Você deve usar o operador spread na variável `addToCartBtns`.
```js
assert.match(code, /\.\.\.addToCartBtns/);
```
You should spread the `addToCartBtns` variable into an array.
Você deve colocar a variável `addToCartBtns` em um array com spread.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]/);
```
You should use the `forEach` method on the array you created.
Você deve usar o método `forEach` no array que você criou.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(/);
```
You should not pass a callback function to the `forEach` method.
Você não deve passar uma função de callback para o método `forEach`.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*\)/);

View File

@@ -7,29 +7,29 @@ dashedName: step-35
# --description--
Add your callback function to the `forEach` method. It should take a `btn` parameter. Then, in the callback, add an event listener to the `btn`. The event listener should listen for a `click` event, and should take another callback with an `event` parameter. The second callback should be empty.
Adicione a função de callback ao método `forEach`. Ela deve receber um único parâmetro `btn`. Em seguida, na função de callback, adicione um "ouvinte" de evento para o `btn`. O "ouvinte" de evento deve escutar um evento de `click` e deve receber outra função de callback com um parâmetro `event`. A segunda função de callback deve estar vazia.
# --hints--
You should use arrow syntax to add a callback function to the `forEach` method which takes a `btn` parameter.
Você deve usar a sintaxe das arrow functions para adicionar uma função de callback ao método `forEach`, que recebe um parâmetro `btn`.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*\(?\s*btn\s*\)?\s*=>\s*\{/);
```
You should add an event listener to the `btn` variable.
Você deve adicionar um "ouvinte" de evento à variável `btn`.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*\(?\s*btn\s*\)?\s*=>\s*\{\s*btn\s*\.\s*addEventListener\s*\(/);
```
You should listen for a `click` event on the `btn` variable.
Você deve escutar um evento de `click` na variável `btn`.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*\(?\s*btn\s*\)?\s*=>\s*\{\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*/);
```
You should add an empty callback function to the event listener. Remember to give it an `event` parameter.
Você deve adicionar uma função de callback vazia ao "ouvinte" de evento. Lembre-se de dar a ele um parâmetro `event`.
```js
assert.match(code, /\[\s*\.\.\.addToCartBtns\s*\]\s*\.\s*forEach\s*\(\s*\(?\s*btn\s*\)?\s*=>\s*\{\s*btn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*\(\s*event\s*\)\s*=>\s*\{\s*\}\s*\)\s*\s*\}\s*\)/);

View File

@@ -7,25 +7,25 @@ dashedName: step-36
# --description--
In your event listener callback, call the `.addItem()` method of your `cart` object, and pass in the `event.target.id`. Remember that the `id` here will be a string, so you need to convert it to a number.
Na função de callback do ouvinte de evento, chame o método `.addItem()` do objeto `cart` e passe `event.target.id`. Lembre-se de que o `id` aqui será uma string. Então, você precisa convertê-la para um número.
Pass your `products` array as the second argument.
Passe o array `products` como o segundo argumento.
# --hints--
Your event listener callback should call the `.addItem()` method of your `cart` object.
A função de callback do ouvinte de evento deve chamar o método `.addItem()` do objeto `cart`.
```js
assert.match(code, /cart\.addItem\(/);
```
Your `.addItem()` method should be called with the `event.target.id` as the first argument. Remember to convert the `id` to a number using `Number()`.
O método `.addItem()` deve ser chamado com o `event.target.id` como o primeiro argumento. Lembre-se de converter o `id` para um número usando `Number()`.
```js
assert.match(code, /cart\.addItem\(\s*Number\(\s*event\.target\.id\s*\)\s*/);
```
Your `.addItem()` method should be called with the `products` array as the second argument.
O método `.addItem()` deve ser chamado com o array `products` como o primeiro argumento.
```js
assert.match(code, /cart\.addItem\(\s*Number\(\s*event\.target\.id\s*\)\s*,\s*products\s*\)/);

View File

@@ -7,26 +7,26 @@ dashedName: step-41
# --description--
You need a way to access the total number of items in the cart. The best way to do this is to add another method to your `ShoppingCart` class, rather than accessing the `items` array directly.
Você precisa de uma maneira de acessar o número total de itens no carrinho. A melhor maneira de se fazer isso é adicionar outro método à classe `ShoppingCart`, em vez de acessar diretamente o array `items`.
Add a `getCounts` method to the `ShoppingCart` class. It should return the number of items in the `items` array.
Adiciona um método `getCounts` à classe `ShoppingCart`. Ele deve retornar o número de itens no array `items`.
# --hints--
Your `ShoppingCart` class should have a `getCounts` method.
A classe `ShoppingCart` deve ter o método `getCounts`.
```js
assert.isFunction(cart.getCounts);
```
Remember to use the `this` keyword to access the `items` array.
Lembre-se de usar a palavra-chave `this` para acessar o array `items`.
```js
const afterCounts = code.split('getCounts')[1];
assert.match(afterCounts, /this\s*\.\s*items\s*\.\s*length/);
```
Your `getCounts` method should return the number of items in the `items` array.
O método `getCounts` deve retornar o número de itens no array `items`.
```js
assert.equal(cart.getCounts(), 0);

View File

@@ -7,17 +7,17 @@ dashedName: step-42
# --description--
Now you can update the total number of items on the webpage. Assign the value of your `cart` object's `.getCounts()` method to the `textContent` of the `totalNumberOfItems` variable.
Agora, você pode atualizar o número total de itens na página da web. Atribua o valor do método `.getCounts()` do objeto `cart` para o `textContent` da variável `totalNumberOfItems`.
# --hints--
You should access the `textContent` property of the `totalNumberOfItems` variable.
Você deve acessar a propriedade `textContent` do elemento `totalNumberOfItems`.
```js
assert.match(code, /totalNumberOfItems\s*\.\s*textContent/)
```
You should assign the value of your `cart` object's `.getCounts()` method to the `textContent` property of the `totalNumberOfItems` variable.
Você deve atribuir o valor do método `.getCounts()` do objeto `cart` para a propriedade `textContent` da variável `totalNumberOfItems`.
```js
assert.match(code, /totalNumberOfItems\s*\.\s*textContent\s*=\s*cart\s*\.\s*getCounts\(\s*\)/)

View File

@@ -7,49 +7,49 @@ dashedName: step-43
# --description--
You also need to update the total price of the cart when the user adds an item. Create a `calculateTotal` method in the `ShoppingCart` class.
Você também precisa atualizar o preço total do carrinho quando o usuário adicionar um item. Crie um método `calculateTotal` na classe `ShoppingCart`.
In that method, declare a `subTotal` variable and use the `reduce` method on the `items` array to calculate the sum of the `price` property of each item in the array. Use `total` and `item` as the parameters for your callback.
Nesse método, declare uma variável `subTotal` e use o método `reduce` no array `items` para calcular a soma da propriedade `price` de cada item no array. Use `total` e `item` como os parâmetros para a função de callback.
Remember to set your initial value in the `reduce` method.
Lembre-se de definir o valor inicial no método `reduce`.
# --hints--
You should create a `calculateTotal` method in the `ShoppingCart` class.
Você deve criar um método `calculateTotal` na classe `ShoppingCart`.
```js
assert.isFunction(cart.calculateTotal);
```
Your `calculateTotal` method should have a `subTotal` variable declared with `const`.
O método `calculateTotal` deve ter uma variável `subTotal` declarada com `const`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /const\s+subTotal\s*=/);
```
Your `calculateTotal` method should use the `reduce` method on the `items` array.
O método `calculateTotal` deve usar o método `reduce` no array `items`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /this\s*\.\s*items\s*\.\s*reduce/);
```
Your `reduce` callback should use `total` and `item` as the first and second parameter. Remember to use arrow function syntax.
A função de callback de `reduce` deve usar `total` e `item` como primeiro e segundo parâmetros. Lembre-se de usar a sintaxe das arrow functions.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /\(\s*total\s*,\s*item\s*\)\s*=>/);
```
Your `reduce` callback should return the sum of `total` and `item.price`. Use an implicit return.
A função de callback de `reduce` deve retornar a soma de `total` e `item.price`. Use um retorno implícito.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /\(\s*total\s*,\s*item\s*\)\s*=>\s*total\s*\+\s*item\.price/);
```
Your `reduce` call should have an initial value of `0`.
A chamada de `reduce` deve ter um valor inicial igual a `0`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];

View File

@@ -7,17 +7,17 @@ dashedName: step-44
# --description--
Part of the total cost will include the tax, so you need to calculate that as well. Create a `calculateTaxes` method in the `ShoppingCart` class. This method should take an `amount` parameter.
Parte do custo total incluirá o imposto. Assim, é necessário calculá-lo também. Crie um método `calculateTaxes` na classe `ShoppingCart`. Esse método deve receber um parâmetro `amount`.
# --hints--
You should create a `calculateTaxes` method in the `ShoppingCart` class.
Você deve criar um método `calculateTaxes` na classe `ShoppingCart`.
```js
assert.isFunction(cart.calculateTaxes);
```
Your `calculateTaxes` method should take an `amount` parameter.
O método `calculateTaxes` deve receber um parâmetro `amount`.
```js
assert.match(cart.calculateTaxes.toString(), /\(\s*amount\s*\)/);

View File

@@ -7,34 +7,34 @@ dashedName: step-45
# --description--
Your `calculateTaxes` method should return the value of the `taxRate` (divided by 100, to convert it to a percent) multiplied by the `amount` parameter.
O método `calculateTaxes` deve retornar o valor de `taxRate` (dividido por 100, para convertê-lo em uma porcentagem) multiplicado pelo parâmetro `amount`.
For clarity, wrap the `taxRate / 100` calculation in parentheses.
Para ser claro, envolva o cálculo de `taxRate / 100` entre parênteses.
# --hints--
You should divide the `taxRate` by 100 in your `calculateTaxes` method. Remember to use the `this` keyword.
Você deve dividir `taxRate` por 100 no método `calculateTaxes`. Lembre-se de usar a palavra-chave `this`.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];
assert.match(afterCalculateTaxes, /this\s*\.\s*taxRate\s*\/\s*100/);
```
You should wrap the `this.taxRate / 100` calculation in parentheses.
Você deve envolver o cálculo de `this.taxRate / 100` entre parênteses.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];
assert.match(afterCalculateTaxes, /\(\s*this\s*\.\s*taxRate\s*\/\s*100\s*\)/);
```
You should multiply the `amount` parameter by the `taxRate` divided by 100 in your `calculateTaxes` method.
Você deve multiplicar o parâmetro `amount` por `taxRate` dividido por 100 no método `calculateTaxes`.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];
assert.match(afterCalculateTaxes, /amount\s*\*\s*\(\s*this\s*\.\s*taxRate\s*\/\s*100\s*\)|\(\s*this\s*\.\s*taxRate\s*\/\s*100\s*\)\s*\*\s*amount/);
```
Your `calculateTaxes` method should return the value of the `taxRate` (divided by 100, to convert it to a percent) multiplied by the `amount` parameter.
O método `calculateTaxes` deve retornar o valor de `taxRate` (dividido por 100, para convertê-lo em uma porcentagem) multiplicado pelo parâmetro `amount`.
```js
console.log(cart.calculateTaxes(10), (cart.taxRate / 100) * 10);

View File

@@ -7,27 +7,27 @@ dashedName: step-46
# --description--
Because of the way computers store and work with numbers, calculations involving decimal numbers can result in some strange behavior. For example, `0.1 + 0.2` is not equal to `0.3`. This is because computers store decimal numbers as binary fractions, and some binary fractions cannot be represented exactly as decimal fractions.
Por causa do modo como os computadores armazenam e trabalham com números, cálculos envolvendo números decimais podem resultar em algum comportamento estranho. Por exemplo, `0.1 + 0.2` não é igual a `0.3`. Isso ocorre porque os computadores armazenam números decimais como frações binárias. Algumas frações binárias não podem ser representadas exatamente como frações decimais.
We want to clean up the number result from your calculation. Wrap your calculation in parentheses (don't include the `return` statement!) and call the `.toFixed()` method on it. Pass the `.toFixed()` method the number `2` as an argument. This will round the number to two decimal places and return a string.
Queremos limpar o resultado numérico do cálculo. Envolva o cálculo entre parênteses (não inclua a instrução `return`!) e chame o método `.toFixed()` nele. Passe o número `2` para o método `.toFixed()` como um argumento. Isso arredondará o número para duas casas decimais e retornará uma string.
# --hints--
You should wrap your calculation in parentheses.
Você deve envolver o cálculo de entre parênteses.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];
assert.match(afterCalculateTaxes, /return\s*\(\s*\(\s*this\s*\.\s*taxRate\s*\/\s*100\s*\)\s*\*\s*amount\s*\)/)
```
You should call the `.toFixed()` method on your calculation.
Você deve chamar o método `.toFixed()` no cálculo.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];
assert.match(afterCalculateTaxes, /return\s*\(\s*\(\s*this\s*\.\s*taxRate\s*\/\s*100\s*\)\s*\*\s*amount\s*\)\s*\.\s*toFixed\(/)
```
You should pass the `.toFixed()` method the number `2` as an argument.
Você deve passar o número `2` para o método `.toFixed()` como um argumento.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];

View File

@@ -7,13 +7,13 @@ dashedName: step-47
# --description--
The issue with `.toFixed()` returning a string is that you want to be able to perform calculations with the tax rate. To fix this, you can pass the `.toFixed()` call (including the calculation) to the `parseFloat()` function. This will convert the fixed string back into a number, preserving the existing decimal places.
O problema com `.toFixed()` retornar uma string é que você quer ser capaz de realizar cálculos com a taxa de imposto. Para corrigir isso, você pode passar a chamada de `.toFixed()` (incluindo o cálculo) para a função `parseFloat()`. Isso converterá a string fixa novamente em um número, preservando as casas decimais existentes.
Pass your `.toFixed()` call to `parseFloat()`.
Passe a chamada de `.toFixed()` para `parseFloat()`.
# --hints--
You should pass your entire calculation (excluding the `return` statement) to `parseFloat()`.
Você deve passar o cálculo inteiro (excluindo a instrução `return`) para `parseFloat()`.
```js
const afterCalculateTaxes = code.split('calculateTaxes')[1];

View File

@@ -7,23 +7,23 @@ dashedName: step-37
# --description--
Your cart currently isn't visible on the webpage. To make it visible, start by adding an event listener to the `cartBtn` variable, listening for the click event. The callback does not need any parameters.
O carrinho, no momento, não está visível na página da web. Para torná-lo visível, comece adicionando um ouvinte de evento à variável `cartBtn`, que escuta o evento de clique. A função de callback não precisa de parâmetros.
# --hints--
You should add an event listener to the `cartBtn` variable.
Você deve adicionar um "ouvinte" de evento à variável `cartBtn`.
```js
assert.match(code, /cartBtn\s*\.\s*addEventListener\s*\(/);
```
You should listen for a `click` event on the `cartBtn` variable.
Você deve escutar um evento de `click` na variável `cartBtn`.
```js
assert.match(code, /cartBtn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*/);
```
You should add an empty callback function (using arrow syntax) to the event listener. Remember that it does not need any parameters.
Você deve adicionar uma função de callback vazia (usando a sintaxe das arrow functions) ao "ouvinte" de evento. Lembre-se de que ela não precisa de parâmetros.
```js
assert.match(code, /cartBtn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/);

View File

@@ -7,17 +7,17 @@ dashedName: step-38
# --description--
Start by inverting the value of `isCartShowing`. Remember that you can use the logical not operator `!` to invert the value of a boolean. Assign the inverted value to `isCartShowing`.
Comece invertendo o valor de `isCartShowing`. Lembre-se de que você pode usar o operador lógico `!` para inverter o valor de um booleano. Atribua o valor invertido a `isCartShowing`.
# --hints--
You should invert the value of `isCartShowing`.
Você deve inverter o valor de `isCartShowing`.
```js
assert.match(code, /!isCartShowing/);
```
You should assign the inverted value of `isCartShowing` to `isCartShowing`.
Você deve atribuir o valor invertido de `isCartShowing` a `isCartShowing`.
```js
assert.match(code, /isCartShowing\s*=\s*!isCartShowing/);

View File

@@ -7,29 +7,29 @@ dashedName: step-39
# --description--
Now assign the `textContent` of the `showHideCartSpan` variable the result of a ternary expression which checks if `isCartShowing` is true. If it is, set the `textContent` to `Hide`, otherwise set it to `Show`.
Agora, atribua ao `textContent` da variável `showHideCartSpan` o resultado de uma expressão ternária que verifica se `isCartShowing` é verdadeiro. Se for, defina `textContent` como `Hide`. Caso contrário, defina-o como `Show`.
# --hints--
You should use the assignment operator on the `textContent` property of the `showHideCartSpan` variable.
Você deve usar o operador da atribuição na propriedade `textContent` da variável `showHideCartSpan`.
```js
assert.match(code, /showHideCartSpan\s*\.\s*textContent\s*=\s*/)
```
You should use ternary syntax to check if `isCartShowing` is true.
Você deve usar sintaxe ternária para verificar se `isCartShowing` é verdadeiro.
```js
assert.match(code, /showHideCartSpan\s*\.\s*textContent\s*=\s*isCartShowing\s*\?\s*/)
```
You should set the `textContent` of the `showHideCartSpan` variable to `Hide` if `isCartShowing` is true.
Você deve definir o `textContent` da variável `showHideCartSpan` como `Hide` se `isCartShowing` for verdadeiro.
```js
assert.match(code, /showHideCartSpan\s*\.\s*textContent\s*=\s*isCartShowing\s*\?\s*('|"|`)Hide\1\s*:\s*/)
```
You should set the `textContent` of the `showHideCartSpan` variable to `Show` if `isCartShowing` is false.
Você deve definir o `textContent` da variável `showHideCartSpan` como `Show` se `isCartShowing` for falso.
```js
assert.match(code, /showHideCartSpan\s*\.\s*textContent\s*=\s*isCartShowing\s*\?\s*('|"|`)Hide\1\s*:\s*('|"|`)Show\2/)

View File

@@ -7,37 +7,37 @@ dashedName: step-40
# --description--
Finally, update the `display` property of the `style` object of the `cartContainer` variable to another ternary which checks if `isCartShowing` is true. If it is, set the `display` property to `block`, otherwise set it to `none`.
Por fim, atualize a propriedade `display` do objeto `style` da variável `cartContainer` para que tenha outro ternário que verifica se `isCartShowing` é verdadeiro. Se for, defina `display` como `block`. Caso contrário, defina-o como `none`.
Now you should be able to see your cart and add items to it.
Agora, você deverá poder ver o carrinho e adicionar produtos a ele.
# --hints--
You should access the `display` property of the `style` property of the `cartContainer` variable.
Você deve acessar a propriedade `display` da propriedade `style` da variável `cartContainer`.
```js
assert.match(code, /cartContainer\s*\.\s*style\s*\.\s*display/)
```
You should use the assignment operator on the `display` property of the `style` property of the `cartContainer` variable.
Você deve acessar o operador de atribuição na propriedade `display` da propriedade `style` da variável `cartContainer`.
```js
assert.match(code, /cartContainer\s*\.\s*style\s*\.\s*display\s*=\s*/)
```
You should use ternary syntax to check if `isCartShowing` is true.
Você deve usar sintaxe ternária para verificar se `isCartShowing` é verdadeiro.
```js
assert.match(code, /cartContainer\s*\.\s*style\s*\.\s*display\s*=\s*isCartShowing\s*\?\s*/)
```
You should set the `display` property of the `style` property of the `cartContainer` variable to `block` if `isCartShowing` is true.
Você deve definir a propriedade `display` da propriedade `style` da variável `cartContainer` como `block` se `isCartShowing` for verdadeiro.
```js
assert.match(code, /cartContainer\s*\.\s*style\s*\.\s*display\s*=\s*isCartShowing\s*\?\s*('|"|`)block\1\s*:\s*/)
```
You should set the `display` property of the `style` property of the `cartContainer` variable to `none` if `isCartShowing` is false.
Você deve definir a propriedade `display` da propriedade `style` da variável `cartContainer` como `none` se `isCartShowing` for falso.
```js
assert.match(code, /cartContainer\s*\.\s*style\s*\.\s*display\s*=\s*isCartShowing\s*\?\s*('|"|`)block\1\s*:\s*('|"|`)none\2/)

View File

@@ -7,18 +7,18 @@ dashedName: step-48
# --description--
Declare a variable `tax` and assign it the value of calling your new `.calculateTaxes()` method, passing `subTotal` as the argument.
Declare uma variável `tax` e atribua a ela o valor da chamada do novo método `.calculateTaxes()`, passando `subTotal` como argumento.
# --hints--
Use `const` to declare a variable named `tax`.
Use `const` para declarar uma variável chamada `tax`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /const\s+tax\s*=/);
```
Assign the value of calling your new `.calculateTaxes()` method, passing `subTotal` as the argument, to the `tax` variable.
Atribua o valor da chamada do novo método `.calculateTaxes()`, passando `subTotal` como argumento, para a variável `tax`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];

View File

@@ -7,17 +7,17 @@ dashedName: step-49
# --description--
Update the `total` value to be the sum of the `subTotal` and `tax` values.
Atualize o valor de `total` para que seja a soma dos valores de `subTotal` e `tax`.
# --hints--
You should update the `total` value. Remember to use the `this` keyword.
Você deve atualizar o valor de `total`. Lembre-se de usar a palavra-chave `this`.
```js
assert.match(cart.calculateTotal.toString(), /this\.total/);
```
You should set the `total` value to be the sum of the `subTotal` and `tax` values.
Você deve definir o valor de `total` para que seja a soma dos valores de `subTotal` e `tax`.
```js
assert.match(cart.calculateTotal.toString(), /this\.total\s*=\s*(subTotal\s*\+\s*tax|tax\s*\+\s*subTotal)/);

View File

@@ -7,30 +7,30 @@ dashedName: step-50
# --description--
You're going to update the HTML in this method as well. Set the `textContent` of the `cartSubTotal` to be the value of `subTotal` to a fixed 2 decimal places. Use template literal syntax to add the dollar sign to the beginning of the value.
Você também vai atualizar o HTML neste método. Defina o `textContent` de `cartSubTotal` como o valor de `subTotal` com 2 casas decimais fixas. Use a sintaxe de template literals para adicionar o sinal de dólar no início do valor.
# --hints--
You should access the `textContent` property of the `cartSubTotal` element.
Você deve acessar a propriedade `textContent` do elemento `cartSubTotal`.
```js
assert.match(cart.calculateTotal.toString(), /cartSubTotal\.textContent/);
```
You should call the `.toFixed()` method on the `subTotal` variable, passing `2` as the argument.
Você deve chamar o método `.toFixed()` na variável `subTotal`, passando `2` como o argumento.
```js
assert.match(cart.calculateTotal.toString(), /subTotal\.toFixed\(\s*2\s*\)/);
```
You should use template literal syntax to add the dollar sign before your `.toFixed()` call.
Você deve usar a sintaxe de template literals para adicionar o sinal de dólar antes da chamada de `.toFixed()`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /`\$\$\{subTotal\.toFixed\(\s*2\s*\)\}\`/);
```
You should set the `textContent` of the `cartSubTotal` element to your template string.
Você deve definir o `textContent` do elemento `cartSubTotal` como uma string de template literals.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];

View File

@@ -7,56 +7,56 @@ dashedName: step-51
# --description--
Following the same pattern as your `cartSubTotal`, update the `cartTaxes` to display the `tax` value, and your `cartTotal` to display the `total` property.
Seguindo o mesmo padrão que o `cartSubTotal`, atualize `cartTaxes` para que exiba o valor de `tax` e para que `cartTotal` exiba a propriedade `total`.
# --hints--
You should access the `textContent` property of the `cartTaxes` element.
Você deve acessar a propriedade `textContent` do elemento `cartTaxes`.
```js
assert.match(cart.calculateTotal.toString(), /cartTaxes\.textContent/);
```
You should call the `.toFixed()` method on the `tax` variable, passing `2` as the argument.
Você deve chamar o método `.toFixed()` na variável `tax`, passando `2` como o argumento.
```js
assert.match(cart.calculateTotal.toString(), /tax\.toFixed\(\s*2\s*\)/);
```
You should use template literal syntax to add the dollar sign before your `.toFixed()` call.
Você deve usar a sintaxe de template literals para adicionar o sinal de dólar antes da chamada de `.toFixed()`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /`\$\$\{tax\.toFixed\(\s*2\s*\)\}\`/);
```
You should set the `textContent` of the `cartTaxes` element to `tax.toFixed` template string.
Você deve definir o `textContent` do elemento `cartTaxes` como a string de template literals `tax.toFixed`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /cartTaxes\.textContent\s*=\s*`\$\$\{tax\.toFixed\(\s*2\s*\)\}\`/);
```
You should access the `textContent` property of the `cartTotal` element.
Você deve acessar a propriedade `textContent` do elemento `cartTotal`.
```js
assert.match(cart.calculateTotal.toString(), /cartTotal\.textContent/);
```
You should call the `.toFixed()` method on the `total` variable, passing `2` as the argument. Remember to use the `this` keyword.
Você deve chamar o método `.toFixed()` na variável `total`, passando `2` como o argumento. Lembre-se de usar a palavra-chave `this`.
```js
assert.match(cart.calculateTotal.toString(), /this\.total\.toFixed\(\s*2\s*\)/);
```
You should use template literal syntax to add the dollar sign before your `.toFixed()` call.
Você deve usar a sintaxe de template literals para adicionar o sinal de dólar antes da chamada de `.toFixed()`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];
assert.match(afterCalculateTotal, /`\$\$\{this\.total\.toFixed\(\s*2\s*\)\}\`/);
```
You should set the `textContent` of the `cartTotal` element to your `total.toFixed` template string.
Você deve definir o `textContent` do elemento `cartTotal` como a string de template literals `total.toFixed`.
```js
const afterCalculateTotal = code.split('calculateTotal')[1];

View File

@@ -7,11 +7,11 @@ dashedName: step-52
# --description--
Finally, return the value of the `total` property. Remember your `this` keyword.
Por fim, retorne o valor de `total`. Lembre-se da palavra chave `this`.
# --hints--
Your `calculateTotal` method should return the value of the `total` property.
O método `calculateTotal` deve retornar o valor da propriedade `total`.
```js
assert.equal(cart.calculateTotal(), 0);

View File

@@ -7,11 +7,11 @@ dashedName: step-54
# --description--
Your last feature is to allow users to clear their cart. Add a `clearCart()` method to your `ShoppingCart` class.
O último recurso é permitir que os usuários limpem o carrinho. Adicione um método `clearCart()` à classe `ShoppingCart`.
# --hints--
Your `ShoppingCart` class should have a `clearCart` method.
A classe `ShoppingCart` deve ter o método `clearCart`.
```js
assert.isFunction(cart.clearCart);

View File

@@ -7,27 +7,27 @@ dashedName: step-55
# --description--
The first thing you should do is check if the `items` array is empty. If it is, display an `alert` to the user with the text `Your shopping cart is already empty`, then return from the function.
A primeira coisa que você deve fazer é verificar se o array `items` está vazio. Se estiver, exiba um `alert` para o usuário com o texto `Your shopping cart is already empty`. Em seguida, retorne a partir da função.
Remember that `0` is a falsy value, so you can use the `!` operator to check if the array is empty.
Lembre-se de que `0` é um valor falso. Assim, você pode usar o operador `!` para verificar se o array está vazio.
After displaying the alert, return from the function to stop execution.
Depois de exibir o alerta, retorne a partir da função para parar a execução.
# --hints--
You should create an `if` statement that checks if the `items` array is empty, using the negation operator.
Você deve criar uma instrução `if` que verifica se o array `items` está vazio, usando o operador de negação.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*!\s*this\s*\.\s*items\s*\.\s*length\s*\)/);
```
Your `if` statement should display an `alert` to the user with the text `Your shopping cart is already empty`.
A instrução `if` deve exibir um `alert` para o usuário com o texto `Your shopping cart is already empty`.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*!\s*this\s*\.\s*items\s*\.\s*length\s*\)\s*\{\s*alert\s*\(\s*('|"|`)Your shopping cart is already empty\1\s*\)\s*/);
```
Your `if` statement should return from the function.
A instrução `if` deve retornar a partir da função.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*!\s*this\s*\.\s*items\s*\.\s*length\s*\)\s*\{\s*alert\s*\(\s*('|"|`)Your shopping cart is already empty\1\s*\)\s*;?\s*return\s*;?\s*\}/);

View File

@@ -7,32 +7,32 @@ dashedName: step-56
# --description--
Browsers have a built-in `confirm()` function which displays a confirmation prompt to the user. `confirm()` accepts a string, which is the message displayed to the user. It returns `true` if the user confirms, and `false` if the user cancels.
Os navegadores têm uma função `confirm()` incorporada que exibe um prompt de confirmação para o usuário. `confirm()` aceita uma string, que é a mensagem exibida ao usuário. Ele retorna `true`, se o usuário confirmar, e `false`, se o usuário cancelar.
Declare a variable `isCartCleared` and assign it the value of calling `confirm()` with the string `"Are you sure you want to clear all items from your shopping cart?"`.
Declare a variável `isCartCleared` e atribua a ela o valor da chamada de `confirm()` com a string `"Are you sure you want to clear all items from your shopping cart?"`.
# --hints--
You should use `const` to declare the `isCartCleared` variable.
Você deve usar `const` para declarar ma variável `isCartCleared`.
```js
const afterClearCart = code.split('clearCart()')[1];
assert.match(afterClearCart, /const\s+isCartCleared\s*=/);
```
You should call the `confirm()` function.
Você deve chamar a função `confirm()`.
```js
assert.match(cart.clearCart.toString(), /confirm\s*\(/);
```
You should pass the string `Are you sure you want to clear all items from your shopping cart?` to the `confirm()` function.
Você deve passar a string `Are you sure you want to clear all items from your shopping cart?` para a função `confirm()`.
```js
assert.match(cart.clearCart.toString(), /confirm\s*\(\s*('|"|`)Are you sure you want to clear all items from your shopping cart\?\1\s*\)/);
```
You should assign the value of the `confirm()` function to the `isCartCleared` variable.
Você deve atribuir o valor da função `confirm()` à variável `isCartCleared`.
```js
assert.match(cart.clearCart.toString(), /isCartCleared\s*=\s*confirm\s*\(\s*('|"|`)Are you sure you want to clear all items from your shopping cart\?\1\s*\)/);

View File

@@ -7,25 +7,25 @@ dashedName: step-57
# --description--
You only want to clear the cart if the user confirms the prompt. Create an `if` statement that checks if the user confirmed the prompt.
Você quer apenas limpar o carrinho se o usuário confirmar o aviso. Crie uma instrução `if` que verifica se o usuário confirmou o aviso.
In the `if` statement, set the `items` property back to an empty array, then set the `total` property to `0`.
Na instrução `if`, defina a propriedade `items` como um array vazio novamente. Em seguida, defina a propriedade `total` como `0`.
# --hints--
You should create an `if` statement that checks if the user confirmed the prompt. Remember that you can check the truthiness of `isCartCleared` directly.
Você deve criar uma instrução `if`, que verifica se o usuário confirmou o aviso. Lembre-se de que você pode verificar o valor verdadeiro de `isCartCleared` diretamente.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*isCartCleared\s*\)/);
```
Your `if` statement should set the `items` property back to an empty array.
A instrução `if` deve definir a propriedade `items` como um array vazio novamente.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*isCartCleared\s*\)\s*{\s*this\s*\.\s*items\s*=\s*\[\s*\]/);
```
Your `if` statement should set the `total` property to `0`.
A instrução `if` deve definir a propriedade `total` como `0`.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*isCartCleared\s*\)\s*{\s*this\s*\.\s*items\s*=\s*\[\s*\]\s*;?\s*this\s*\.\s*total\s*=\s*0\s*;?\s*}/);

View File

@@ -7,11 +7,11 @@ dashedName: step-58
# --description--
You also need to start clearing the HTML. Set the `innerHTML` property of the `productsContainer` back to an empty string.
Você também precisa começar a limpar o HTML. Defina a propriedade `innerHTML` de `productsContainer` como uma string vazia novamente.
# --hints--
In your `if` statement, you should set the `innerHTML` property of the `productsContainer` back to an empty string.
Na instrução `if`, você deve definir a propriedade `innerHTML` de `productsContainer` como uma string vazia novamente.
```js
assert.match(cart.clearCart.toString(), /if\s*\(\s*isCartCleared\s*\)\s*{\s*this\s*\.\s*items\s*=\s*\[\s*\]\s*;?\s*this\s*\.\s*total\s*=\s*0\s*;?\s*productsContainer\.innerHTML\s*=\s*('|"|`)\1\s*;?\s*}/);

View File

@@ -7,11 +7,11 @@ dashedName: step-59
# --description--
Set the `textContent` of the `totalNumberOfItems`, `cartSubTotal`, `cartTaxes`, and `cartTotal` elements all to the number `0`.
Defina o `textContent` dos elementos `totalNumberOfItems`, `cartSubTotal`, `cartTaxes` e `cartTotal` como o número `0`.
# --hints--
You should set the `textContent` of the `totalNumberOfItems` element to `0`.
Você deve definir o `textContent` do elemento `totalNumberOfItems` como `0`.
```js
const secondIf = cart.clearCart.toString().split('if')[2];
@@ -19,7 +19,7 @@ const inIf = secondIf.split('}')[0];
assert.match(inIf, /totalNumberOfItems\.textContent\s*=\s*0/);
```
You should set the `textContent` of the `cartSubTotal` element to `0`.
Você deve definir o `textContent` do elemento `cartSubTotal` como `0`.
```js
const secondIf = cart.clearCart.toString().split('if')[2];
@@ -27,7 +27,7 @@ const inIf = secondIf.split('}')[0];
assert.match(inIf, /cartSubTotal\.textContent\s*=\s*0/);
```
You should set the `textContent` of the `cartTaxes` element to `0`.
Você deve definir o `textContent` do elemento `cartTaxes` como `0`.
```js
const secondIf = cart.clearCart.toString().split('if')[2];
@@ -35,7 +35,7 @@ const inIf = secondIf.split('}')[0];
assert.match(inIf, /cartTaxes\.textContent\s*=\s*0/);
```
You should set the `textContent` of the `cartTotal` element to `0`.
Você deve definir o `textContent` do elemento `cartTotal` como `0`.
```js
const secondIf = cart.clearCart.toString().split('if')[2];

View File

@@ -7,29 +7,29 @@ dashedName: step-60
# --description--
Your final step is to make your clear button functional. Add a `click` event listener to the `clearCartBtn`. For the callback, you can pass in `cart.clearCart` directly.
O último passo é deixar seu botão de limpar funcional. Adicione um ouvinte do evento de `click` para `clearCartBtn`. Para a função de callback, você pode passar `cart.clearCart` diretamente.
However, doing so will not work, because the context of `this` will be the `clearCartBtn` element. You need to bind the `clearCart` method to the `cart` object.
No entanto, fazer isso não funcionará, pois o contexto de `this` será o elemento `clearCartBtn`. Você precisa vincular o método `clearCart` ao objeto `cart`.
You can do this by passing `cart.clearCart.bind(cart)` as the callback.
Você pode fazer isso passando `cart.clearCart.bind(cart)` como função de callback.
And with that, your shopping cart project is complete!
Com isso, o projeto do carrinho de compras está completo!
# --hints--
You should add an event listener to your `clearCartBtn` element.
Você deve adicionar um "ouvinte" de evento à variável `clearCartBtn`.
```js
assert.match(code, /clearCartBtn\.addEventListener\(/);
```
Your event listener should listen for the `click` event.
O "ouvinte" de evento deve "ouvir" o evento de `click`.
```js
assert.match(code, /clearCartBtn\.addEventListener\(\s*('|"|`)click\1\s*,/);
```
Your event listener should take `cart.clearCart.bind(cart)` as the callback.
O ouvinte de evento deve receber `cart.clearCart.bind(cart)` como função de callback.
```js
assert.match(code, /clearCartBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*cart\.clearCart\s*.bind\(\s*cart\s*\)\s*\)/);

View File

@@ -7,11 +7,11 @@ dashedName: step-53
# --description--
Now call your `.calculateTotal()` method inside your `forEach` loop.
Agora, chame o método `.calculateTotal()` dentro do laço `forEach`.
# --hints--
You should call `cart.calculateTotal()` inside your `forEach` loop.
Você deve chamar o método `cart.calculateTotal()` dentro do laço `forEach`.
```js
const afterForEach = code.split('[...addToCartBtns].forEach(')[1];

View File

@@ -7,55 +7,55 @@ dashedName: step-4
# --description--
Create a `fieldset` element with the `id` set to `breakfast`.
Crie um elemento `fieldset` com o `id` definido como `breakfast`.
Within that element, create a `legend` with the text `Breakfast`, and an empty `div` with the `class` set to `input-container`.
Dentro desse elemento, crie uma `legend` com o texto `Breakfast` e uma `div` vazia com a `class` definida como `input-container`.
# --hints--
You should create a `fieldset` element in your `form`.
Você deve criar um elemento `fieldset` no `form`.
```js
assert.exists(document.querySelector('form fieldset'));
```
Your `fieldset` element should come after your `input` element.
O elemento `fieldset` deve vir depois do elemento `input`.
```js
assert.equal(document.querySelector('form fieldset')?.previousElementSibling?.tagName, "INPUT");
```
Your `fieldset` element should have an `id` set to `breakfast`.
O elemento `fieldset` deve ter o atributo `id` definido como `breakfast`.
```js
assert.equal(document.querySelector('form fieldset')?.id, "breakfast");
```
You should create a `legend` element within your `fieldset`.
Você deve criar um elemento `legend` no `fieldset`.
```js
assert.exists(document.querySelector('form fieldset legend'));
```
Your `legend` element should have the text `Breakfast`.
O elemento `legend` deve ter o texto `Breakfast`.
```js
assert.equal(document.querySelector('form fieldset legend')?.innerText, "Breakfast");
```
You should create a `div` element within your `fieldset`.
Você deve criar um elemento `div` no `fieldset`.
```js
assert.exists(document.querySelector('form fieldset div'));
```
Your `div` element should come after your `legend` element.
O elemento `div` deve vir depois do elemento `legend`.
```js
assert.equal(document.querySelector('form fieldset div')?.previousElementSibling?.tagName, "LEGEND");
```
Your `div` element should have a `class` set to `input-container`.
O elemento `div` deve ter uma `class` definida como `input-container`.
```js
assert.equal(document.querySelector('form fieldset div')?.className, "input-container");

View File

@@ -7,30 +7,30 @@ dashedName: step-12
# --description--
Your form needs somewhere to display the results. Add an empty `div` element and give it an `id` of `output` and the `class` values of `output` and `hide`.
O formulário precisa de um lugar para exibir os resultados. Adicione um elemento `div` vazio e dê a ele um `id` de `output` e os valores de `class` de `output` e `hide`.
# --hints--
You should add a `div` element after your `form`.
Você deve adicionar um elemento `div` depois do `form`.
```js
assert.exists(document.querySelector('.container > div'));
```
Your new `div` element should have an `id` set to `output`.
O novo elemento `div` deve ter o `id` definido como `output`.
```js
assert.equal(document.querySelector('.container > div')?.id, 'output');
```
Your new `div` element should have the `class` values of `output` and `hide`.
O novo elemento `div` deve ter os valores de `class` definidos como `output` e `hide`.
```js
assert.include(document.querySelector('.container > div')?.className.split(/\s+/), 'output');
assert.include(document.querySelector('.container > div')?.className.split(/\s+/), 'hide');
```
Your new `div` should be empty.
A nova `div` deve estar vazia.
```js
assert.equal(document.querySelector('.container > div')?.innerHTML, '');

View File

@@ -7,59 +7,59 @@ dashedName: step-16
# --description--
Following the same pattern, assign your `#add-entry` element to `addEntryButton`, your `#clear` element to `clearButton`, and your `#output` element to `output`.
Seguindo o mesmo padrão, atribua o elemento `#add-entry` a `addEntryButton`, o elemento `#clear` ao `clearButton` e o elemento `#output` a `output`.
# --hints--
You should declare a variable called `addEntryButton`.
Você deve declarar uma variável chamada `addEntryButton`.
```js
assert.isDefined(addEntryButton);
```
You should use `document.getElementById()` to get the `#add-entry` element.
Você deve usar `document.getElementById()` para obter o elemento `#add-entry`.
```js
assert.match(code, /document\.getElementById\(\s*('|")add-entry\1\s*\)/g);
```
You should assign the `#add-entry` element to `addEntryButton`.
Você deve atribuir o elemento `#add-entry` a `addEntryButton`.
```js
assert.equal(addEntryButton, document.getElementById('add-entry'));
```
You should declare a variable called `clearButton`.
Você deve declarar uma variável chamada `clearButton`.
```js
assert.isDefined(clearButton);
```
You should use `document.getElementById()` to get the `#clear` element.
Você deve usar `document.getElementById()` para obter o elemento `#clear`.
```js
assert.match(code, /document\.getElementById\(\s*('|")clear\1\s*\)/g);
```
You should assign the `#clear` element to `clearButton`.
Você deve atribuir o elemento `#clear` a `clearButton`.
```js
assert.equal(clearButton, document.getElementById('clear'));
```
You should declare a variable called `output`.
Você deve declarar uma variável chamada `output`.
```js
assert.isDefined(output);
```
You should use `document.getElementById()` to get the `#output` element.
Você deve usar `document.getElementById()` para obter o elemento `#output`.
```js
assert.match(code, /document\.getElementById\(\s*('|")output\1\s*\)/g);
```
You should assign the `#output` element to `output`.
Você deve atribuir o elemento `#output` a `output`.
```js
assert.equal(output, document.getElementById("output"));

View File

@@ -7,17 +7,17 @@ dashedName: step-30
# --description--
Declare a `regex` variable, and assign it a regex that matches the character `e`.
Declare uma variável `regex` e atribua a ela uma expressão regular que corresponda ao caractere `e`.
# --hints--
Your `isInvalidInput` function should have a `regex` variable.
A função `isInvalidInput` deve ter uma variável `regex`.
```js
assert.match(isInvalidInput.toString(), /regex\s*=/);
```
Your `regex` variable should be set to `/e/`.
A variável `regex` deve ser definida como `/e/`.
```js
assert.match(isInvalidInput.toString(), /regex\s*=\s*\/e\//);

View File

@@ -7,17 +7,17 @@ dashedName: step-34
# --description--
There is a shorthand character class to match any digit: `\d`. Replace your `[0-9]` character classes with this shorthand.
Há uma versão abreviada da classe de caracteres que corresponde a qualquer algarismo: `\d`. Substitua a classe de caracteres `[0-9]` por essa versão abreviada.
# --hints--
You should replace the `[0-9]` character class before `e` with `\d` in your regular expression.
Você deve substituir a classe de caracteres `[0-9]` antes de `e` por `\d` na sua expressão regular.
```js
assert.match(isInvalidInput.toString(), /regex\s*=\s*\/\\d\+e/);
```
You should replace the `[0-9]` character class after `e` with `\d` in your regular expression.
Você deve substituir a classe de caracteres `[0-9]` após o `e` por `\d` na sua expressão regular.
```js
assert.match(isInvalidInput.toString(), /regex\s*=\s*\/\\d\+e\\d\+\//);

View File

@@ -7,23 +7,23 @@ dashedName: step-40
# --description--
Thanks to template literals, you actually don't need the `targetId` variable at all. Remove that variable, and update your template literal to replace `targetId` with `entryDropdown.value` remember to add `#` before that, in the string.
Graças aos template literals, você, na verdade, não precisa da variável `targetId`. Remova essa variável e atualize seu template literal para substituir `targetId` por `entryDropdown.value` lembre-se de adicionar `#` antes disso, na string.
# --hints--
You should remove the `targetId` variable.
Você deve remover a variável `targetId`.
```js
assert.notMatch(addEntry.toString(), /targetId\s*=/);
```
You should replace the `targetId` reference in your template literal with `entryDropdown.value`.
Você deve substituir a referência a `targetId` no template literal por `entryDropdown.value`.
```js
assert.match(code, /const\s+targetInputContainer\s*=\s*document\.querySelector\(`#?\$\{entryDropdown\.value\}\s\.input-container`\s*\)/);
```
You should add `#` at the beginning of your template literal.
Você deve adicionar `#` ao início do template literal.
```js
assert.match(code, /const\s+targetInputContainer\s*=\s*document\.querySelector\(`#\$\{entryDropdown\.value\}\s\.input-container`\s*\)/);

View File

@@ -7,27 +7,27 @@ dashedName: step-42
# --description--
Each entry will have a text input for the entry's name, and a number input for the calories. To get a count of the number of entries, you can query by text inputs. Note that you cannot query by number inputs, as you have an extra number input for the user's calorie budget.
Cada entrada terá um input de texto para o nome da entrada e um input numérico para as calorias. Para obter uma contagem do número de entradas, você pode consultar por inputs de texto. Observe que você não pode consultar por inputs numéricos, já que você tem um input numérico a mais para o orçamento de calorias do usuário.
Pass the string `input[type="text"]` to the `querySelectorAll()` method. Remember that you will need to use single quotes for your string, so that you can use double quotes within.
Passe a string `input[type="text"]` para o método `querySelectorAll()`. Lembre-se de que você precisará usar aspas simples para a string, de modo a poder usar aspas duplas dentro delas.
This will return a `NodeList` of all the text inputs in the form. You can then access the `length` property of the `NodeList` to get the number of entries. Do this on the same line.
Isso retornará uma `NodeList` de todos os inputs de texto do formulário. Você pode, então, acessar a propriedade `length` de `NodeList` para obter o número de entradas. Faça isso na mesma linha.
# --hints--
You should pass the string `input[type="text"]` to the `querySelectorAll()` method.
Você deve passar a string `input[type="text"]` para o método `querySelectorAll()`.
```js
assert.match(addEntry.toString(), /entryNumber\s*=\s*targetInputContainer\.querySelectorAll\(\s*'input\[type="text"]'\)/)
```
You should access the `length` property of your `querySelectorAll()`.
Você deve acessar a propriedade `length` de `querySelectorAll()`.
```js
assert.match(addEntry.toString(), /\.querySelectorAll\(\s*'input\[type="text"]'\)\.length/)
```
Your `entryNumber` variable should be the `length` of the `querySelectorAll`.
A variável `entryNumber` deve ser a `length` de `querySelectorAll`.
```js
assert.match(addEntry.toString(), /entryNumber\s*=\s*targetInputContainer\.querySelectorAll\(\s*'input\[type="text"]'\)\.length/)

View File

@@ -9,9 +9,9 @@ dashedName: step-60
Remember that your `isInvalidInput` function returns `String.match`, which is an array of matches or `null` if no matches are found.
In JavaScript, values can either be <dfn>truthy</dfn> or <dfn>falsy</dfn>. A value is truthy if it evaluates to `true` when converted to a Boolean. A value is falsy if it evaluates to `false` when converted to a Boolean. `null` is an example of a falsy value.
In JavaScript, values can either be <dfn>truthy</dfn> or <dfn>falsy</dfn>. A value is truthy if it evaluates to `true` when converted to a Boolean. Um valor é considerado falso se ele for avaliado como `false` quando convertido em um booleano. `null` é um exemplo de um valor falso.
You need to check if `invalidInputMatch` is truthy you can do this by passing the variable directly to your `if` condition (without a comparison operator). Here's an example of checking the truthiness of `helloWorld`.
Você precisa verificar se `invalidInputMatch` é avaliado como verdadeiro você pode fazer isso passando a variável diretamente para a condição de `if` (sem um operador de comparação). Aqui está um exemplo de como avaliar se algo é verdadeiro com `helloWorld`.
```js
if (helloWorld) {
@@ -19,23 +19,23 @@ if (helloWorld) {
}
```
Add an `if` statement that checks if `invalidInputMatch` is truthy.
Adicione uma instrução `if` que verifica se `invalidInputMatch` é avaliado como verdadeiro.
# --hints--
You should add an `if` statement to your `getCaloriesFromInputs` function.
Você deve adicionar uma instrução `if` à função `getCaloriesFromInputs`.
```js
assert.match(getCaloriesFromInputs.toString(), /if\s*\(/);
```
You should check the truthiness of `invalidInputMatch` in your `if` condition.
Você deve avaliar se `invalidInputMatch` é verdadeiro na condição de `if`.
```js
assert.match(getCaloriesFromInputs.toString(), /if\s*\(\s*invalidInputMatch\s*\)/);
```
Your `if` statement should be inside your `for` loop.
A instrução `if` deve estar dentro do laço `for`.
```js
assert.isBelow(getCaloriesFromInputs.toString().indexOf("for"), getCaloriesFromInputs.toString().indexOf("if"));

View File

@@ -7,17 +7,17 @@ dashedName: step-64
# --description--
After your `for` loop has completed, return the `calories` value.
Depois da conclusão do seu laço `for`, retorne o valor de `calories`.
# --hints--
You should `return` the `calories` value.
Você deve usar `return` para retornar o valor de `calories`.
```js
assert.match(getCaloriesFromInputs.toString(), /return\s+calories/);
```
Your new `return` statement should come after your `for` loop.
A nova instrução `return` deve vir após o laço `for`.
```js
assert.match(getCaloriesFromInputs.toString(), /calories\s*\+=\sNumber\(currVal\);\n\s*}\n\s*return\s+calories/)

View File

@@ -7,29 +7,29 @@ dashedName: step-75
# --description--
It is time to start preparing your calculations. Start by declaring a `consumedCalories` variable, and assign it the sum of `breakfastCalories`, `lunchCalories`, `dinnerCalories`, and `snacksCalories` (note that order matters for the tests). Be sure to do this after your `if` statement.
Está na hora de começar a preparar os cálculos. Comece declarando uma variável `consumedCalories` e atribua a ela a soma de `breakfastCalories`, `lunchCalories`, `dinnerCalories` e `snacksCalories` (observe que a ordem é importante para os testes). Certifique-se de que fazer isso após a instrução `if`.
# --hints--
Your function should have a `consumedCalories` variable.
A função deve ter uma variável `consumedCalories`.
```js
assert.match(calculateCalories.toString(), /consumedCalories\s*=/);
```
Your `consumedCalories` variable should come after your `if` statement.
A variável `consumedCalories` deve vir depois da instrução `if`.
```js
assert.isAbove(calculateCalories.toString().indexOf('consumedCalories'), calculateCalories.toString().indexOf('if'));
```
You should calculate the sum of `breakfastCalories`, `lunchCalories`, `dinnerCalories`, and `snacksCalories`, in order.
Você deve calcular a soma de `breakfastCalories`, `lunchCalories`, `dinnerCalories` e `snacksCalories`, na ordem.
```js
assert.match(calculateCalories.toString(), /breakfastCalories\s*\+\s*lunchCalories\s*\+\s*dinnerCalories\s*\+\s*snacksCalories/);
```
You should assign the sum of `breakfastCalories`, `lunchCalories`, `dinnerCalories`, and `snacksCalories` to `consumedCalories`.
Você deve calcular a soma de `breakfastCalories`, `lunchCalories`, `dinnerCalories` e `snacksCalories` para `consumedCalories`.
```js
assert.match(calculateCalories.toString(), /consumedCalories\s*=\s*breakfastCalories\s*\+\s*lunchCalories\s*\+\s*dinnerCalories\s*\+\s*snacksCalories/);

View File

@@ -7,34 +7,34 @@ dashedName: step-79
# --description--
Your `output.innerHTML` string will need a `span` element. Create that, and give it a `class` attribute set to the `surplusOrDeficit` variable, but lowercased.
A string de `output.innerHTML` precisará de um elemento `span`. Crie o elemento e dê a ele um atributo `class` definido como a variável `surplusOrDeficit`, mas em minúsculas.
Strings have a `.toLowerCase()` method that can help you with this. Do not give your `span` any text yet.
Strings têm um método `.toLowerCase()` que pode ajudar você com isso. Não coloque texto no `span` por enquanto.
# --hints--
You should create a `span` element in your template literal.
Você deve criar um elemento `span` no seu template literal.
```js
const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/`/)[1];
assert.match(htmlString, /<span/);
```
Your `span` element should have a `class` attribute.
O elemento `span` deve ter um atributo `class`.
```js
const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/`/)[1];
assert.match(htmlString, /<span\s+class\s*=/);
```
Your `span` should have the `class` attribute set to `surplusOrDeficit.toLowerCase()`.
O `span` deve ter o atributo `class` definido como `surplusOrDeficit.toLowerCase()`.
```js
const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/`/)[1];
assert.match(htmlString, /<span\s+class\s*=\s*"\$\{surplusOrDeficit\s*\.toLowerCase\(\s*\)\}"\s*>/);
```
Your `span` should not have any text.
O `span` não deve ter texto.
```js
const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/`/)[1];

View File

@@ -7,23 +7,23 @@ dashedName: step-87
# --description--
Your final feature to add is the ability for a user to clear the form. Start by declaring an empty function called `clearForm` it should not take any arguments.
O recurso final a ser adicionado é a capacidade de um usuário limpar o formulário. Comece declarando uma função vazia chamada `clearForm` ela não deve receber nenhum argumento.
# --hints--
You should declare a `clearForm` variable.
Você deve declarar uma variável `clearForm`.
```js
assert.isDefined(clearForm);
```
Your `clearForm` variable should be a function.
A variável `clearForm` deve ser uma função.
```js
assert.isFunction(clearForm);
```
Your `clearForm` function should not take any arguments.
A função `clearForm` não deve receber nenhum argumento.
```js
assert.match(clearForm?.toString(), /\(\s*\)/);

View File

@@ -7,25 +7,25 @@ dashedName: step-92
# --description--
You also need to clear the `output` element's text. You can do this by setting the `innerText` property to an empty string.
Você também precisa limpar o texto do elemento `output`. Você deve fazer isso definindo a propriedade `innerText` como uma string vazia.
The difference between `innerText` and `innerHTML` is that `innerText` will not render HTML elements, but will display the tags and content as raw text.
A diferença entre `innerText` e `innerHTML` é que `innerText` não renderizará elementos do HTML, mas exibirá as tags e o conteúdo como texto bruto.
# --hints--
Your `clearForm` function should access the `innerText` property of the `output` element.
A função `clearForm` deve acessar a propriedade `innerText` do elemento `output`.
```js
assert.match(clearForm.toString(), /output\.innerText/);
```
Your `clearForm` function should set the `innerText` property of the `output` element to an empty string.
A função `clearForm` deve definir a propriedade `innerText` do elemento `output` como uma string vazia.
```js
assert.match(clearForm.toString(), /output\.innerText\s*=\s*('|"|`)\1/);
```
You should modify `output` after modifying `budgetNumberInput`.
Você deve modificar `output` após modificar `budgetNumberInput`.
```js
assert.isAbove(clearForm.toString().indexOf('output'), clearForm.toString().indexOf('budgetNumberInput'));