Beau Carnes f334734e98
feat: split JS challenge into two (#39044)
* feat: split JS challenge into two

* fix/change-to-not-use-untaught-assignments

Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com>
2020-08-31 19:44:56 +01:00

1.7 KiB

id, title, challengeType, isHidden, videoUrl, forumTopicId
id title challengeType isHidden videoUrl forumTopicId
56533eb9ac21ba0edf2244a8 Storing Values with the Assignment Operator 1 false https://scrimba.com/c/cEanysE 18310

Description

In JavaScript, you can store a value in a variable with the assignment operator (=). myVariable = 5; This assigns the Number value 5 to myVariable. If there are any calculations to the right of the = operator, those are performed before the value is assigned to the variable on the left of the operator.
var myVar;
myVar = 5;

First, this code creates a variable named myVar. Then, the code assigns 5 to myVar. Now, if myVar appears again in the code, the program will treat it as if it is 5.

Instructions

Assign the value 7 to variable a.

Tests

tests:
  - text: You should not change code above the specified comment.
    testString: assert(/var a;/.test(code));
  - text: <code>a</code> should have a value of 7.
    testString: assert(typeof a === 'number' && a === 7);

Challenge Seed

// Setup
var a;

// Only change code below this line

Before Test

if (typeof a != 'undefined') {
  a = undefined;
}

After Test

(function(a){return "a = " + a;})(a);

Solution

var a;
a = 7;