Discuss Scratch

StarscreamClone
Scratcher
1000+ posts

More JavaScript Grief...

Yeah, I'm pretty sure I'm getting on people's nerves with my constant mistakes, but I seem to be making a lot of them. Sorry for the inconvenience.

Anyhow, here's the info:

Lesson name:
Variables, ‘Change Variable Values’

Instructions:
(In code)

My code:
// On line 2, declare a variable myName and give it your name.
var variableName ="myName";
myName="Dark Surge";

// On line 4, use console.log to print out the myName variable.
console.log(myName)

// On line 7, change the value of myName to be just the first 2
// letters of your name
myName=console.log("Dark Surge".substring(0,2));

// On line 9, use console.log to print out the myName variable.
console.log(myName);

Error message:
Oops, try again! Did you set myName equal to your name, like this: myName = ‘Leng’?

Thanks again!

Last edited by StarscreamClone (Aug. 8, 2013 23:29:28)

CAA14
Scratcher
500+ posts

More JavaScript Grief...

StarscreamClone wrote:

Yeah, I'm pretty sure I'm getting on people's nerves with my constant mistakes, but I seem to be making a lot of them. Sorry for the inconvenience.

Anyhow, here's the info:

Lesson name:
Variables, ‘Change Variable Values’

Instructions:
(In code)

My code:
// On line 2, declare a variable myName and give it your name.
var variableName ="myName";
myName="Dark Surge";

// On line 4, use console.log to print out the myName variable.
console.log(myName)

// On line 7, change the value of myName to be just the first 2
// letters of your name
myName=console.log("Dark Surge".substring(0,2));

// On line 9, use console.log to print out the myName variable.
console.log(myName);

Error message:
Oops, try again! Did you set myName equal to your name, like this: myName = ‘Leng’?

Thanks again!
Though it's been a few months since my last programming in Javascript, i think your problem is this:

In the first instruction, You need to Change it to this:

var myName =“Dark Surge”;


I believe that should fix it.
Remember, you don't need to tell the variable what it is(Except in type, but i am not sure JavaScript separates the types), just what it equals.

I hope this helps.


Also, as long as that fixed it, you could do the third instruction a bit more efficiently, though it doesn't really matter here, like this:

myName=console.log(myName.substring(0,2));

Last edited by CAA14 (Aug. 8, 2013 23:53:29)

StarscreamClone
Scratcher
1000+ posts

More JavaScript Grief...

CAA14 wrote:

StarscreamClone wrote:

Yeah, I'm pretty sure I'm getting on people's nerves with my constant mistakes, but I seem to be making a lot of them. Sorry for the inconvenience.

Anyhow, here's the info:

Lesson name:
Variables, ‘Change Variable Values’

Instructions:
(In code)

My code:
// On line 2, declare a variable myName and give it your name.
var variableName ="myName";
myName="Dark Surge";

// On line 4, use console.log to print out the myName variable.
console.log(myName)

// On line 7, change the value of myName to be just the first 2
// letters of your name
myName=console.log("Dark Surge".substring(0,2));

// On line 9, use console.log to print out the myName variable.
console.log(myName);

Error message:
Oops, try again! Did you set myName equal to your name, like this: myName = ‘Leng’?

Thanks again!
Though it's been a few months since my last programming in Javascript, i think your problem is this:

In the first instruction, You need to Change it to this:

var myName =“Dark Surge”;


I believe that should fix it.
Remember, you don't need to tell the variable what it is(Except in type, but i am not sure JavaScript separates the types), just what it equals.

I hope this helps.


Also, as long as that fixed it, you could do the third instruction a bit more efficiently, though it doesn't really matter here, like this:

myName=console.log(myName.substring(0,2));
Thanks!
StarscreamClone
Scratcher
1000+ posts

More JavaScript Grief...

It still says it's not right… I'll google search the lesson; it might have a glitch like ‘Bordering on Insanity’ did.
StarscreamClone
Scratcher
1000+ posts

More JavaScript Grief...

Ah, I got it! I had an extra console.log
CAA14
Scratcher
500+ posts

More JavaScript Grief...

StarscreamClone wrote:

Ah, I got it! I had an extra console.log
Oh, okay.
StarscreamClone
Scratcher
1000+ posts

More JavaScript Grief...

CAA14 wrote:

StarscreamClone wrote:

Ah, I got it! I had an extra console.log
Oh, okay.
I hate variables. They're such pains…
Paddle2See
Scratch Team
1000+ posts

More JavaScript Grief...

Closed by request of the topic owner.

Powered by DjangoBB