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)


I generally go by Surgeus now | Somewhere in my 20s | He/Him/It
Software dev, VR entertainer, student (CS and cognitive science) and future president of 2036!

Surge is my imaginary husband - he's the guy in my icon!
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)


Engine Center! Check it out! 6 Engine's to jump start your project! - Jumper! Collect Gold in style! - Birds the arcade game! - Mind blowing math challenge!
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!

I generally go by Surgeus now | Somewhere in my 20s | He/Him/It
Software dev, VR entertainer, student (CS and cognitive science) and future president of 2036!

Surge is my imaginary husband - he's the guy in my icon!
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.

I generally go by Surgeus now | Somewhere in my 20s | He/Him/It
Software dev, VR entertainer, student (CS and cognitive science) and future president of 2036!

Surge is my imaginary husband - he's the guy in my icon!
StarscreamClone
Scratcher
1000+ posts

More JavaScript Grief...

Ah, I got it! I had an extra console.log

I generally go by Surgeus now | Somewhere in my 20s | He/Him/It
Software dev, VR entertainer, student (CS and cognitive science) and future president of 2036!

Surge is my imaginary husband - he's the guy in my icon!
CAA14
Scratcher
500+ posts

More JavaScript Grief...

StarscreamClone wrote:

Ah, I got it! I had an extra console.log
Oh, okay.

Engine Center! Check it out! 6 Engine's to jump start your project! - Jumper! Collect Gold in style! - Birds the arcade game! - Mind blowing math challenge!
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…

I generally go by Surgeus now | Somewhere in my 20s | He/Him/It
Software dev, VR entertainer, student (CS and cognitive science) and future president of 2036!

Surge is my imaginary husband - he's the guy in my icon!
Paddle2See
Scratch Team
1000+ posts

More JavaScript Grief...

Closed by request of the topic owner.

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;

Powered by DjangoBB

Standard | Mobile