Can someone please help me understand this topic?

Tell us what’s happening:
Describe your issue in detail here.

Your code so far


// Only change code below this line
var a = 6;
var b = 15;
var c = i am a;
// Only change code above this line

a = a + 1;
b = b + 5;
c = c + " String!";

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36

Challenge: Understanding Uninitialized Variables

Link to the challenge:

1 Like

???


I don’t understand how this code would be written

As per the question, it states: Initialize the three variables a , b , and c with 5 , 10 , and "I am a" respectively so that they will not be undefined .
However, when I enter in the code above, it doesn’t work and I don’t understand as to why that is?

6 is not 5
15 is not 10
i am a is not "I am a"

// Only change code below this line

var myVara = 5;

var myVarb = 10;

var myVarc = iama;

// Only change code above this line

a = a + 1;

b = b + 5;

c = c + " String!";

is this correct then?

The instructions did not say to rename your variables.

Also, this still is not the string “I am a”

1 Like

I am very new to Java and I have no idea how to create a string

(Note: You’re learning JavaScript, not Java)

The instructions say

Initialize the three variables a , b , and c with 5 , 10 , and "I am a" respectively

so, have you exactly, character for character, initialized the three variables with the precise values given in the instructions? No, you forgot to include the quotation marks ".

1 Like

If its in quotes it is considered a string in javascript. so “this is a string”. and even though 10 is a number, if i put it in quotes “10” is now considered a string. I believe you are before the curriculum goes more in depth on it, so don’t worry, just know that you need “quotes” for a string.

1 Like

Thank you so much for explaining in detail.

Thank you so much for explaining :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.