Files
freeCodeCamp/curriculum/challenges/ukrainian/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md
2023-01-30 18:58:54 +02:00

1.5 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244ad Декремент числа з JavaScript 1 https://scrimba.com/c/cM2KeS2 17558 decrement-a-number-with-javascript

--description--

Ви можете легко зменшити або відняти одиницю від змінної за допомогою оператора --.

i--;

те й саме, що

i = i - 1;

Примітка: весь рядок стає i--;, усуваючи потребу в знаку рівності.

--instructions--

Змініть код, щоб використати оператор -- на myVar.

--hints--

myVar має дорівнювати 10.

assert(myVar === 10);

myVar = myVar - 1; потрібно змінити.

assert(!code.match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));

Ви не повинні присвоювати 10 до myVar.

assert(!code.match(/myVar\s*=\s*10.*?;?/));

Ви повинні використати оператор -- на myVar.

assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));

Не змінюйте код над зазначеним коментарем.

assert(/let myVar = 11;/.test(code));

--seed--

--after-user-code--

(function(z){return 'myVar = ' + z;})(myVar);

--seed-contents--

let myVar = 11;

// Only change code below this line
myVar = myVar - 1;

--solutions--

let myVar = 11;
myVar--;