mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-28 21:00:56 +08:00
chore(i18n,learn): processed translations (#50097)
This commit is contained in:
parent
6e1d2fb760
commit
7dcfc402dd
@ -7,29 +7,29 @@ dashedName: step-35
|
||||
|
||||
# --description--
|
||||
|
||||
Aggiungi la funzione callback al metodo `forEach`. Dovrebbe prendere un parametro `btn`. Poi, nella callback, aggiungi un event listener al `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.
|
||||
Aggiungi la funzione callback al metodo `forEach`. Dovrebbe prendere un parametro `btn`. Poi, nella callback, aggiungi un event listener al `btn`. L'event listener dovrebbe essere in ascolto per l'evento `click` e dovrebbe prendere un'altra callback con un parametro `event`. La seconda callback dovrebbe essere vuota.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use arrow syntax to add a callback function to the `forEach` method which takes a `btn` parameter.
|
||||
Dovresti usare la sintassi freccia per aggiungere una funzione callback al metodo `forEach` che richiede un parametro `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.
|
||||
Dovresti aggiungere un event listener alla variabile `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.
|
||||
Dovresti ascoltare l'evento `click` sulla variabile `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.
|
||||
Dovresti aggiungere una funzione callback vuota all'event listener. Ricordati di darle un parametro `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*\)/);
|
||||
|
||||
@ -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.
|
||||
Nella callback dell'event listener, chiama il metodo `.addItem()` sull'oggetto `cart` e passagli `event.target.id`. Ricorda che l'`id` è una stringa, quindi dovrai convertirla in un numero.
|
||||
|
||||
Pass your `products` array as the second argument.
|
||||
Passa l'array `products` come secondo argomento.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your event listener callback should call the `.addItem()` method of your `cart` object.
|
||||
La callback dell'event listener dovrebbe chiamare il metodo `.addItem()` sull'oggetto `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()`.
|
||||
Il metodo `.addItem()` dovrebbe essere chiamato con `event.target.id` come primo argomento. Ricordati di convertire l'`id` in un numero 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.
|
||||
Il metodo `.addItem()` dovrebbe essere chiamato con l'array `products` come secondo argomento.
|
||||
|
||||
```js
|
||||
assert.match(code, /cart\.addItem\(\s*Number\(\s*event\.target\.id\s*\)\s*,\s*products\s*\)/);
|
||||
|
||||
@ -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.
|
||||
Ti serve un modo per accedere al numero totale di articoli nel carrello. Il modo migliore per farlo è aggiungere un altro metodo alla classe `ShoppingCart`, invece di accedere direttamente all'array `items`.
|
||||
|
||||
Add a `getCounts` method to the `ShoppingCart` class. It should return the number of items in the `items` array.
|
||||
Aggiungi un metodo `getCounts` alla classe `ShoppingCart`. Dovrebbe restituire il numero di oggetti nell'array `items`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `ShoppingCart` class should have a `getCounts` method.
|
||||
La classe `ShoppingCart` dovrebbe avere un metodo `getCounts`.
|
||||
|
||||
```js
|
||||
assert.isFunction(cart.getCounts);
|
||||
```
|
||||
|
||||
Remember to use the `this` keyword to access the `items` array.
|
||||
Ricordati di utilizzare la parola chiave `this` per accedere all'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.
|
||||
Il metodo `getCounts` dovrebbe restituire il numero di elementi nell'array `items`.
|
||||
|
||||
```js
|
||||
assert.equal(cart.getCounts(), 0);
|
||||
|
||||
@ -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.
|
||||
Ora puoi aggiornare il numero totale di articoli sulla pagina web. Assegna il valore del metodo `.getCounts()` dell'oggetto `cart` al `textContent` della variabile `totalNumberOfItems`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the `textContent` property of the `totalNumberOfItems` variable.
|
||||
Dovresti accedere alla proprietà `textContent` della variabile `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.
|
||||
Dovresti assegnare il valore del metodo `.getCounts()` dell'oggetto `cart` al `textContent` della variabile `totalNumberOfItems`.
|
||||
|
||||
```js
|
||||
assert.match(code, /totalNumberOfItems\s*\.\s*textContent\s*=\s*cart\s*\.\s*getCounts\(\s*\)/)
|
||||
|
||||
@ -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.
|
||||
Devi anche aggiornare il prezzo totale del carrello quando l'utente aggiunge un articolo. Crea un metodo `calculateTotal` nella 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.
|
||||
In questo metodo, dichiara una variabile `subTotal` e usa il metodo `reduce` sull'array `items` per calcolare la somma della proprietà `price` di ogni elemento nell'array. Usa `total` e `item` come parametri per la callback.
|
||||
|
||||
Remember to set your initial value in the `reduce` method.
|
||||
Ricordati di impostare il valore iniziale nel metodo `reduce`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a `calculateTotal` method in the `ShoppingCart` class.
|
||||
Dovresti creare un metodo `calculateTotal` nella classe `ShoppingCart`.
|
||||
|
||||
```js
|
||||
assert.isFunction(cart.calculateTotal);
|
||||
```
|
||||
|
||||
Your `calculateTotal` method should have a `subTotal` variable declared with `const`.
|
||||
Il metodo `calculateTotal` dovrebbe avere una variabile `subTotal` dichiarata con `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.
|
||||
Il metodo `calculateTotal` dovrebbe utilizzare il metodo `reduce` sull'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.
|
||||
La callback di `reduce` dovrebbe utilizzare `total` e `item` come primo e secondo parametro. Ricorda di utilizzare la sintassi della funzione freccia.
|
||||
|
||||
```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.
|
||||
La callback di `reduce` dovrebbe restituire la somma di `total` e `item.price`. Utilizza un return implicito.
|
||||
|
||||
```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`.
|
||||
La callback di `reduce` dovrebbe avere un valore iniziale di `0`.
|
||||
|
||||
```js
|
||||
const afterCalculateTotal = code.split('calculateTotal')[1];
|
||||
|
||||
@ -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.
|
||||
Part of the total cost will include the tax, so you need to calculate that as well. Crea un metodo `calculateTaxes` nella classe `ShoppingCart`. Questo metodo dovrebbe prendere un parametro `amount`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a `calculateTaxes` method in the `ShoppingCart` class.
|
||||
Dovresti creare un metodo `calculateTaxes` nella classe `ShoppingCart`.
|
||||
|
||||
```js
|
||||
assert.isFunction(cart.calculateTaxes);
|
||||
```
|
||||
|
||||
Your `calculateTaxes` method should take an `amount` parameter.
|
||||
Il metodo `calculateTaxes` dovrebbe prendere un parametro `amount`.
|
||||
|
||||
```js
|
||||
assert.match(cart.calculateTaxes.toString(), /\(\s*amount\s*\)/);
|
||||
|
||||
@ -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.
|
||||
Il metodo `calculateTaxes` dovrebbe restituire il valore di `taxRate` (diviso per 100, per convertirlo in percentuale) moltiplicato per il parametro `amount`.
|
||||
|
||||
For clarity, wrap the `taxRate / 100` calculation in parentheses.
|
||||
Per chiarezza, racchiudi il calcolo `taxRate / 100` tra parentesi.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should divide the `taxRate` by 100 in your `calculateTaxes` method. Remember to use the `this` keyword.
|
||||
Dovresti dividere `taxRate` per 100 nel metodo `calculateTaxes`. Ricordati di usare la parola chiave `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.
|
||||
Dovresti racchiudere il calcolo `this.taxRate / 100` tra parentesi.
|
||||
|
||||
```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.
|
||||
Dovresti moltiplicare il parametro `amount` per `taxRate` diviso 100 nel metodo `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.
|
||||
Il metodo `calculateTaxes` dovrebbe restituire il valore di `taxRate` (diviso per 100, per convertirlo in percentuale) moltiplicato per il parametro `amount`.
|
||||
|
||||
```js
|
||||
console.log(cart.calculateTaxes(10), (cart.taxRate / 100) * 10);
|
||||
|
||||
@ -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.
|
||||
A causa del modo in cui i computer memorizzano e lavorano con i numeri, i calcoli che comportano numeri decimali possono portare a qualche comportamento strano. Ad esempio, `0.1 + 0.2` non è uguale a `0.3`. Questo perché i computer memorizzano i numeri decimali come frazioni binarie e alcune non possono essere rappresentate esattamente come frazioni decimali.
|
||||
|
||||
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.
|
||||
Vogliamo ripulire il risultato numerico del calcolo. Racchiudi il calcolo tra parentesi (non includere l'istruzione `return`!) e chiama su di esso il metodo `.toFixed()`. Passa al metodo `.toFixed()` il numero `2` come argomento. Questo arrotonderà il numero a due decimali e restituirà una stringa.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should wrap your calculation in parentheses.
|
||||
Dovresti racchiudere il calcolo tra parentesi.
|
||||
|
||||
```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.
|
||||
Dovresti chiamare il metodo `.toFixed()` sul calcolo.
|
||||
|
||||
```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.
|
||||
Dovresti passare al metodo `.toFixed()` il numero `2` come argomento.
|
||||
|
||||
```js
|
||||
const afterCalculateTaxes = code.split('calculateTaxes')[1];
|
||||
|
||||
@ -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.
|
||||
Il problema con `.toFixed()` che restituisce una stringa è che vuoi essere in grado di eseguire calcoli con l'aliquota fiscale. Per risolvere questo problema, puoi passare la chiamata `.toFixed()` (incluso il calcolo) alla funzione `parseFloat()`. Questo riconvertirà la stringa fissa in un numero, preservando le posizioni decimali esistenti.
|
||||
|
||||
Pass your `.toFixed()` call to `parseFloat()`.
|
||||
Passa la chiamata `.toFixed()` a `parseFloat()`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should pass your entire calculation (excluding the `return` statement) to `parseFloat()`.
|
||||
Dovresti passare l'intero calcolo (esclusa l'istruzione `return`) a `parseFloat()`.
|
||||
|
||||
```js
|
||||
const afterCalculateTaxes = code.split('calculateTaxes')[1];
|
||||
|
||||
@ -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.
|
||||
Il carrello attualmente non è visibile nella pagina web. Per renderlo visibile, inizia aggiungendo un event listener alla variabile `cartBtn`, in ascolto per l'evento click. La callback non ha bisogno di alcun parametro.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should add an event listener to the `cartBtn` variable.
|
||||
Dovresti aggiungere un event listener alla variabile `cartBtn`.
|
||||
|
||||
```js
|
||||
assert.match(code, /cartBtn\s*\.\s*addEventListener\s*\(/);
|
||||
```
|
||||
|
||||
You should listen for a `click` event on the `cartBtn` variable.
|
||||
Dovresti ascoltare l'evento `click` sulla variabile `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.
|
||||
Dovresti aggiungere una funzione callback vuota (usando la sintassi freccia) all'event listener. Ricorda che non ha bisogno di alcun parametro.
|
||||
|
||||
```js
|
||||
assert.match(code, /cartBtn\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/);
|
||||
|
||||
@ -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`.
|
||||
Inizia invertendo il valore di `isCartShowing`. Ricorda che puoi usare l'operatore logico `!` per invertire il valore di un booleano. Assegna il valore invertito a `isCartShowing`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should invert the value of `isCartShowing`.
|
||||
Dovresti invertire il valore di `isCartShowing`.
|
||||
|
||||
```js
|
||||
assert.match(code, /!isCartShowing/);
|
||||
```
|
||||
|
||||
You should assign the inverted value of `isCartShowing` to `isCartShowing`.
|
||||
Dovresti assegnare il valore invertito di `isCartShowing` a `isCartShowing`.
|
||||
|
||||
```js
|
||||
assert.match(code, /isCartShowing\s*=\s*!isCartShowing/);
|
||||
|
||||
@ -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`.
|
||||
Ora assegna al `textContent` della variabile `showHideCartSpan` il risultato di un'espressione ternaria che controlla se `isCartShowing` è vero. Se lo è, imposta il `textContent` su `Hide`, altrimenti impostalo su `Show`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the assignment operator on the `textContent` property of the `showHideCartSpan` variable.
|
||||
Dovresti utilizzare l'operatore di assegnazione sulla proprietà `textContent` della variabile `showHideCartSpan`.
|
||||
|
||||
```js
|
||||
assert.match(code, /showHideCartSpan\s*\.\s*textContent\s*=\s*/)
|
||||
```
|
||||
|
||||
You should use ternary syntax to check if `isCartShowing` is true.
|
||||
Dovresti usare la sintassi ternaria per controllare se `isCartShowing` è vero.
|
||||
|
||||
```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.
|
||||
Dovresti impostare il `textContent` della variabile `showHideCartSpan` su `Hide` se `isCartShowing` è vero.
|
||||
|
||||
```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.
|
||||
Dovresti impostare il `textContent` della variabile `showHideCartSpan` su `Show` se `isCartShowing` è falso.
|
||||
|
||||
```js
|
||||
assert.match(code, /showHideCartSpan\s*\.\s*textContent\s*=\s*isCartShowing\s*\?\s*('|"|`)Hide\1\s*:\s*('|"|`)Show\2/)
|
||||
|
||||
@ -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`.
|
||||
Infine, aggiorna la proprietà `display` dell'oggetto `style` della variabile `cartContainer` in un altro ternario che controlla se `isCartShowing` è vero. Se lo è, imposta `display` su `block`, altrimenti impostalo su `none`.
|
||||
|
||||
Now you should be able to see your cart and add items to it.
|
||||
Ora dovresti essere in grado di vedere il carrello e aggiungergli articoli.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the `display` property of the `style` property of the `cartContainer` variable.
|
||||
Dovresti accedere alla proprietà `display` della proprietà `style` della variabile `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.
|
||||
Dovresti usare l'operatore di assegnazione sulla proprietà `display` della proprietà `style` della variabile `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.
|
||||
Dovresti usare la sintassi ternaria per controllare se `isCartShowing` è vero.
|
||||
|
||||
```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.
|
||||
Dovresti impostare la proprietà `display` dell'oggetto `style` della variabile `cartContainer` su `block` se `isCartShowing` è vero.
|
||||
|
||||
```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.
|
||||
Dovresti impostare la proprietà `display` dell'oggetto `style` della variabile `cartContainer` su `none` se `isCartShowing` è falso.
|
||||
|
||||
```js
|
||||
assert.match(code, /cartContainer\s*\.\s*style\s*\.\s*display\s*=\s*isCartShowing\s*\?\s*('|"|`)block\1\s*:\s*('|"|`)none\2/)
|
||||
|
||||
@ -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.
|
||||
Dichiara una variabile `tax` e assegnale il valore della chiamata del nuovo metodo `.calculateTaxes()`, passando `subTotal` come argomento.
|
||||
|
||||
# --hints--
|
||||
|
||||
Use `const` to declare a variable named `tax`.
|
||||
Usa `const` per dichiarare una variabile chiamata `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.
|
||||
Assegna il valore della chiamata del nuovo metodo `.calculateTaxes()`, passando `subTotal` come argomento alla variabile `tax`.
|
||||
|
||||
```js
|
||||
const afterCalculateTotal = code.split('calculateTotal')[1];
|
||||
|
||||
@ -7,17 +7,17 @@ dashedName: step-49
|
||||
|
||||
# --description--
|
||||
|
||||
Update the `total` value to be the sum of the `subTotal` and `tax` values.
|
||||
Aggiorna il valore di `total` con la somma dei valori di `subTotal` e `tax`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update the `total` value. Remember to use the `this` keyword.
|
||||
Dovresti aggiornare il valore di `total`. Ricorda di usare la parola chiave `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.
|
||||
Dovresti aggiornare il valore di `total` con la somma dei valori di `subTotal` e `tax`.
|
||||
|
||||
```js
|
||||
assert.match(cart.calculateTotal.toString(), /this\.total\s*=\s*(subTotal\s*\+\s*tax|tax\s*\+\s*subTotal)/);
|
||||
|
||||
@ -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.
|
||||
Stai per aggiornare anche l'HTML in questo metodo. Imposta il `textContent` di `cartSubTotal` in modo che sia il valore di `subTotal` con un numero fisso di 2 decimali. Usa la sintassi del template literal per aggiungere il segno del dollaro all'inizio del valore.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the `textContent` property of the `cartSubTotal` element.
|
||||
Dovresti accedere alla proprietà `textContent` dell'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.
|
||||
Dovresti chiamare il metodo `.toFixed()` sulla variabile `subTotal`, passando `2` come argomento.
|
||||
|
||||
```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.
|
||||
Dovresti usare la sintassi del template literal per aggiungere il segno del dollaro prima della chiamata `.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.
|
||||
Dovresti impostare il `textContent` dell'elemento `cartSubTotal` sulla stringa template.
|
||||
|
||||
```js
|
||||
const afterCalculateTotal = code.split('calculateTotal')[1];
|
||||
|
||||
@ -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.
|
||||
Seguendo lo stesso modello di `cartSubTotal`, aggiorna `cartTaxes` per visualizzare il valore di `tax` e `cartTotal` per visualizzare la proprietà `total`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the `textContent` property of the `cartTaxes` element.
|
||||
Dovresti accedere alla proprietà `textContent` dell'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.
|
||||
Dovresti chiamare il metodo `.toFixed()` sulla variabile `tax`, passando `2` come argomento.
|
||||
|
||||
```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.
|
||||
Dovresti usare la sintassi del template literal per aggiungere il segno del dollaro prima della chiamata `.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.
|
||||
Dovresti impostare il `textContent` dell'elemento `cartTaxes` sulla stringa template `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.
|
||||
Dovresti accedere alla proprietà `textContent` dell'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.
|
||||
Dovresti chiamare il metodo `.toFixed()` sulla variabile `total`, passando `2` come argomento. Ricordati di usare la parola chiave `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.
|
||||
Dovresti usare la sintassi del template literal per aggiungere il segno del dollaro prima della chiamata `.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.
|
||||
Dovresti impostare il `textContent` dell'elemento `cartTotal` sulla stringa template `total.toFixed`.
|
||||
|
||||
```js
|
||||
const afterCalculateTotal = code.split('calculateTotal')[1];
|
||||
|
||||
@ -7,11 +7,11 @@ dashedName: step-52
|
||||
|
||||
# --description--
|
||||
|
||||
Finally, return the value of the `total` property. Remember your `this` keyword.
|
||||
Infine, restituisci il valore della proprietà `total`. Ricordati di usare la parola chiave `this`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `calculateTotal` method should return the value of the `total` property.
|
||||
Il metodo `calculateTotal` dovrebbe restituire il valore della proprietà `total`.
|
||||
|
||||
```js
|
||||
assert.equal(cart.calculateTotal(), 0);
|
||||
|
||||
@ -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.
|
||||
L'ultima funzionalità è permettere agli utenti di svuotare il carrello. Aggiungi un metodo `clearCart()` alla classe `ShoppingCart`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `ShoppingCart` class should have a `clearCart` method.
|
||||
La classe `ShoppingCart` dovrebbe avere un metodo `clearCart`.
|
||||
|
||||
```js
|
||||
assert.isFunction(cart.clearCart);
|
||||
|
||||
@ -7,7 +7,7 @@ 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.
|
||||
La prima cosa che dovresti fare è controllare se l'array `items` è vuoto. If it is, display an `alert` to the user with the text `Your shopping cart is already empty`, then return from the function.
|
||||
|
||||
Remember that `0` is a falsy value, so you can use the `!` operator to check if the array is empty.
|
||||
|
||||
|
||||
@ -7,11 +7,11 @@ dashedName: step-53
|
||||
|
||||
# --description--
|
||||
|
||||
Now call your `.calculateTotal()` method inside your `forEach` loop.
|
||||
Ora chiama il metodo `.calculateTotal()` all'interno del loop `forEach`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should call `cart.calculateTotal()` inside your `forEach` loop.
|
||||
Dovresti chiamare `cart.calculateTotal()` all'interno del loop `forEach`.
|
||||
|
||||
```js
|
||||
const afterForEach = code.split('[...addToCartBtns].forEach(')[1];
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f37b1000cf542c50fe8e
|
||||
title: 'Problem 15: Lattice paths'
|
||||
title: 'Завдання 15: доріжки на сітці'
|
||||
challengeType: 1
|
||||
forumTopicId: 301780
|
||||
dashedName: problem-15-lattice-paths
|
||||
@ -8,11 +8,11 @@ dashedName: problem-15-lattice-paths
|
||||
|
||||
# --description--
|
||||
|
||||
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
|
||||
Починаючи з верхнього лівого кутка сітки 2×2 та маючи право рухатися лише вправо чи вниз, дійти до нижнього правого кутка можна 6 шляхами.
|
||||
|
||||
<img class="img-responsive center-block" alt="a diagram of 6 2 by 2 grids showing all the routes to the bottom right corner" src="https://cdn-media-1.freecodecamp.org/project-euler/1Atixoj.gif" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="зображення з шістьма сітками 2 на 2, що показує усі шляхи до нижнього правого кутка" src="https://cdn-media-1.freecodecamp.org/project-euler/1Atixoj.gif" style="background-color: white; padding: 10px;" />
|
||||
|
||||
How many such routes are there through a given `gridSize`?
|
||||
Скільки таких шляхів можна прокласти для наданої `gridSize`?
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f37d1000cf542c50fe8f
|
||||
title: 'Problem 16: Power digit sum'
|
||||
title: 'Завдання 16: сума цифр степеня'
|
||||
challengeType: 1
|
||||
forumTopicId: 301791
|
||||
dashedName: problem-16-power-digit-sum
|
||||
@ -8,9 +8,9 @@ dashedName: problem-16-power-digit-sum
|
||||
|
||||
# --description--
|
||||
|
||||
2<sup>15</sup> = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
|
||||
2<sup>15</sup> = 32768, а сума цифр цього числа дорівнює 3 + 2 + 7 + 6 + 8 = 26.
|
||||
|
||||
What is the sum of the digits of the number 2<sup><code>exponent</code></sup>?
|
||||
Якою буде сума цифр степеня 2<sup><code>exponent</code></sup>?
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f37d1000cf542c50fe90
|
||||
title: 'Problem 17: Number letter counts'
|
||||
title: 'Завдання 17: підрахунок букв у числах'
|
||||
challengeType: 1
|
||||
forumTopicId: 301804
|
||||
dashedName: problem-17-number-letter-counts
|
||||
@ -8,11 +8,11 @@ dashedName: problem-17-number-letter-counts
|
||||
|
||||
# --description--
|
||||
|
||||
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
|
||||
Якщо числа від 1 до 5 записати словами (one, two, three, four, five), то загалом буде використано 3 + 3 + 5 + 4 + 4 = 10 букв.
|
||||
|
||||
If all the numbers from 1 to given `limit` inclusive were written out in words, how many letters would be used?
|
||||
Якщо числа від 1 до заданого `limit` включно записати словами, скільки букв потрібно було б використати?
|
||||
|
||||
**Note:** Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.
|
||||
**Примітка:** не враховуйте пробіли чи дефіси. Наприклад, 342 (three hundred and forty-two) складається з 23 букв, а 115 (one hundred and fifteen) — з 20. Використання «and» при написанні чисел відповідає правилам Британської англійської.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f37e1000cf542c50fe91
|
||||
title: 'Problem 18: Maximum path sum I'
|
||||
title: 'Завдання 18: максимальна сума шляху I'
|
||||
challengeType: 1
|
||||
forumTopicId: 301815
|
||||
dashedName: problem-18-maximum-path-sum-i
|
||||
@ -8,7 +8,7 @@ dashedName: problem-18-maximum-path-sum-i
|
||||
|
||||
# --description--
|
||||
|
||||
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.
|
||||
Якщо почати з вершини трикутника, зображеного нижче, і рухатись до суміжних чисел у нижньому рядку, максимальною сумою зверху вниз буде 23.
|
||||
|
||||
<span style='display: block; text-align: center;'>
|
||||
<strong style='color: red;'>3</strong><br>
|
||||
@ -17,9 +17,9 @@ By starting at the top of the triangle below and moving to adjacent numbers on t
|
||||
8 5 <strong style='color: red;'>9</strong> 3
|
||||
</span>
|
||||
|
||||
That is, 3 + 7 + 4 + 9 = 23.
|
||||
Тобто 3 + 7 + 4 + 9 = 23.
|
||||
|
||||
Find the maximum total from top to bottom of the triangle below:
|
||||
Знайдіть максимальну суму шляху від вершини до основи у трикутнику, зображеному нижче:
|
||||
|
||||
75
|
||||
95 64
|
||||
@ -37,7 +37,7 @@ Find the maximum total from top to bottom of the triangle below:
|
||||
63 66 04 68 89 53 67 30 73 16 69 87 40 31
|
||||
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
|
||||
|
||||
**NOTE:** As there are only 16384 routes, it is possible to solve this problem by trying every route. However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute force, and requires a clever method! ;o)
|
||||
**Примітка:** оскільки у цьому разі є лише 16384 шляхи, то дане завдання можна розв’язати, перевіривши кожен маршрут. Однак завдання №67 містить таку ж саму задачу із трикутником, що має 100 рядків і яку потрібно розв’язати не силою, а розумом! ;o)
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f37f1000cf542c50fe92
|
||||
title: 'Problem 19: Counting Sundays'
|
||||
title: 'Завдання 19: підрахунок неділь'
|
||||
challengeType: 1
|
||||
forumTopicId: 301827
|
||||
dashedName: problem-19-counting-sundays
|
||||
@ -8,15 +8,15 @@ dashedName: problem-19-counting-sundays
|
||||
|
||||
# --description--
|
||||
|
||||
You are given the following information, but you may prefer to do some research for yourself.
|
||||
Нижче наведена певна інформація, але ви можете зробити дослідження самостійно.
|
||||
|
||||
<ul>
|
||||
<li>1 Jan 1900 was a Monday.</li>
|
||||
<li>Thirty days has September,<br>April, June and November.<br>All the rest have thirty-one,<br>Saving February alone,<br>Which has twenty-eight, rain or shine.<br>And on leap years, twenty-nine.</li>
|
||||
<li>A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.</li>
|
||||
<li>1 січня 1900 року було понеділком.</li>
|
||||
<li>По 30 днів налічують вересень,<br>квітень, червень та листопад.<br>Усі інші — по 31 дню,<br>не враховуючи лютий,<br>який зазвичай має 28 днів.<br>А у високосні роки — 29 днів.</li>
|
||||
<li>Високосний рік випадає на рік, який рівно ділиться на 4, але це не стосується сторіччя, хіба що воно кратне 400.</li>
|
||||
</ul>
|
||||
|
||||
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
|
||||
Скільки неділь випало на перше число місяця протягом двадцятого сторіччя (від 1 січня 1901 по 31 грудня 2000)?
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3801000cf542c50fe93
|
||||
title: 'Problem 20: Factorial digit sum'
|
||||
title: 'Завдання 20: сума цифр факторіала'
|
||||
challengeType: 1
|
||||
forumTopicId: 301839
|
||||
dashedName: problem-20-factorial-digit-sum
|
||||
@ -8,12 +8,12 @@ dashedName: problem-20-factorial-digit-sum
|
||||
|
||||
# --description--
|
||||
|
||||
`n`! means `n` × (`n` − 1) × ... × 3 × 2 × 1
|
||||
`n`! означає `n` × (`n` − 1) × ... × 3 × 2 × 1
|
||||
|
||||
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
|
||||
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
|
||||
Наприклад, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
|
||||
і сума цифр у числі 10! дорівнює 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
|
||||
|
||||
Find the sum of the digits `n`!
|
||||
Знайдіть суму цифр у `n`!
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user