I need help with undefined and i do not know what to do

I need help with undefined and i do not know what to do
0

#1

Tell us what’s happening:
i am stock on this undefined please help

Your code so far


// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1; var a=6
b = b + 5; var b=15
c = c + " String!";  var="i am a string!"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables


#2

Take a look at that third line, var="i am a string!" – var is a reserved word. Also, you’re changing values below the line where it says not to – and you’re going to get an error for redefining a var in those lines.

You may want to set the values where they are being declared…


#3

thanks snowmonkey you are valid


#4

var=" i am a string!"
not working


#5

and it won’t. You’re doing two things wrong: first, you’re redefining existing values. Second, you have no variable name in that var="i amm a string!" line. Both of those things should be throwing errors.

Instead, you have a point above where the variable names are defined:

var a;
var b;
var c;

why not simply set the values for those three RIGHT THERE?


#6

Tell us what’s happening:

Your code so far


// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1; var a=6
b = b + 5; var b=15
c = c + " String!"; var c="I am a"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables


#7

Dude, you already asked this. I already answered clearly, doing everything short of GIVING you the answer. You’re redefining the variables. You’re adding code where it says DO NOT CHANGE CODE BELOW THIS LINE.

It explicitly says to inititialize these three variables. At that point, simply set their value ON THE LINE WHERE THEY ARE BEING CREATED.


#8

You keep liking my responses, but are you understanding them?


#9

what is the problem exactly?


#10

Let’s try this.

  1. This is declaring a variable.

var variableName;

Right now it’s value is undefined, you can think of it as empty for now.

  1. This is initializing*, or assigning to, the above declared variable a value.

variableName = "someStringValue";

  1. This is declaring and initializing/assigning the variable in one line.

var variableName = "someStringValue";

Not sure if this will help


  • On a side note, and i realize this is probably not at all the right place for this comment, but anyway.

I would like some clarification on this myself. So anyone, please correct me if I am wrong. I actually believe using the word initialize is incorrect, it should be assign not initialize. To my understanding, initialization refers to the memory allocation stage. When the code runs declared variables are initialized in memory and implicitly assigned the value undefined.

6.1.1The Undefined Type#
The Undefined type has exactly one value, called undefined. Any variable that has not been assigned a value has the value undefined.

This might just be terminological nitpicking, and i know i have seen the word initialize used as meaning assigning plenty of places, by people far smarter than me.
Thoughts, comments?


I can't solve this: Understanding Uninitialized Variables
#11

i appreciate your effort of making me get this but i am sorry it is not working, i9 will prefer a direct solution to get over this


#12

#13

I have closed this duplicate thread, because you are receiving responses in the other thread.

This is exactly why we do not want users to create multiple topics for the same question.