freeCodeCamp/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.english.md
Oliver Eyton-Williams bd68b70f3d
Feat: hide blocks not challenges (#39504)
* fix: remove isHidden flag from frontmatter

* fix: add isUpcomingChange

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

* feat: hide blocks not challenges

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2020-09-03 15:07:40 -07:00

1.1 KiB

id, title, challengeType, videoUrl, forumTopicId
id title challengeType videoUrl forumTopicId
56533eb9ac21ba0edf2244a9 Initializing Variables with the Assignment Operator 1 https://scrimba.com/c/cWJ4Bfb 301171

Description

It is common to initialize a variable to an initial value in the same line as it is declared. var myVar = 0; Creates a new variable called myVar and assigns it an initial value of 0.

Instructions

Define a variable a with var and initialize it to a value of 9.

Tests

tests:
  - text: You should initialize <code>a</code> to a value of <code>9</code>.
    testString: assert(/var\s+a\s*=\s*9\s*/.test(code));

Challenge Seed



After Test

if(typeof a !== 'undefined') {(function(a){return "a = " + a;})(a);} else { (function() {return 'a is undefined';})(); }

Solution

var a = 9;