2.3 KiB
2.3 KiB
id, title, localeTitle, challengeType
id | title | localeTitle | challengeType |
---|---|---|---|
56533eb9ac21ba0edf2244a8 | Storing Values with the Assignment Operator | Almacenamiento de valores con el operador de asignación | 1 |
Description
myVariable = 5;
Esto asigna el valor Number
5
a myVariable
.
asignación siempre va de derecha a izquierda. Todo a la derecha del operador =
se resuelve antes de que el valor se asigne a la variable a la izquierda del operador.
myVar = 5;Esto asigna
myNum = myVar;
5
a myVar
y luego resuelve myVar
a 5
nuevamente y lo asigna a myNum
.
Instructions
7
a la variable a
.
Asigna los contenidos de a
a la variable b
.
Tests
tests:
- text: No cambie el código por encima de la línea
testString: 'assert(/var a;/.test(code) && /var b = 2;/.test(code), "Do not change code above the line");'
- text: <code class = "notranslate"> a </code> debe tener un valor de 7
testString: 'assert(typeof a === "number" && a === 7, "<code>a</code> should have a value of 7");'
- text: <code class = "notranslate"> b </code> debe tener un valor de 7
testString: 'assert(typeof b === "number" && b === 7, "<code>b</code> should have a value of 7");'
- text: <code class = "notranslate"> a </code> debe asignarse a <code class = "notranslate"> b </code> con <code class = "notranslate"> = </code>
testString: 'assert(/b\s*=\s*a\s*;/g.test(code), "<code>a</code> should be assigned to <code>b</code> with <code>=</code>");'
Challenge Seed
// Setup
var a;
var b = 2;
// Only change code below this line
Before Test
if (typeof a != 'undefined') {
a = undefined;
}
if (typeof b != 'undefined') {
b = undefined;
}
After Test
console.info('after the test');
Solution
var a;
var b = 2;
a = 7;
b = a;