You are viewing our Forum Archives. To view or take place in current topics click here.
Would this work CODE (Learning)
Posted:

Would this work CODE (Learning)Posted:

-Lara
  • New Member
Status: Offline
Joined: Aug 10, 201310Year Member
Posts: 46
Reputation Power: 1
Status: Offline
Joined: Aug 10, 201310Year Member
Posts: 46
Reputation Power: 1
Ok im just started learning about codeing so this is what i came up with.its Java Scrip
by the way im 14

Here what i started with

"MyName+" "+MyStatement + " " Myfavoritenumber+" ";

Then this was what i finished with.

Alert(MyName + "Kieran" + Mystatement + "LikesTheNumber" MyFavoritenumber + "4";

Would this work and again im new
#2. Posted:
UnrealEgg
  • Powerhouse
Status: Offline
Joined: May 30, 201014Year Member
Posts: 438
Reputation Power: 49
Status: Offline
Joined: May 30, 201014Year Member
Posts: 438
Reputation Power: 49
There's a few things wrong with your code.

I see what you're trying to achieve through concatenating variables. However you must set the variables data elsewhere before doing so. I think you got a bit confused and tried to assign them whilst concatenating.

Anyhow, a great place to start and test would be [ Register or Signin to view external links. ] . You'll see I fixed your code up.
#3. Posted:
-Lara
  • New Member
Status: Offline
Joined: Aug 10, 201310Year Member
Posts: 46
Reputation Power: 1
Status: Offline
Joined: Aug 10, 201310Year Member
Posts: 46
Reputation Power: 1
UnrealEgg wrote There's a few things wrong with your code.

I see what you're trying to achieve through concatenating variables. However you must set the variables data elsewhere before doing so. I think you got a bit confused and tried to assign them whilst concatenating.

Anyhow, a great place to start and test would be [ Register or Signin to view external links. ] . You'll see I fixed your code up.
Thanks alot if its Ok i ask qustions when im stumped at points
#4. Posted:
var
  • TTG Senior
Status: Offline
Joined: Dec 24, 201211Year Member
Posts: 1,498
Reputation Power: 79
Status: Offline
Joined: Dec 24, 201211Year Member
Posts: 1,498
Reputation Power: 79
You need to concatenate "LikesTheNumber" with MyFavoritenumber then preceed the semicolon with a parenthesis since you opened one after alert. Other than that the code should be fine, assuming you've initialized your variables somewhere before this code runs..

Also "4" and 4 are different.. Not sure which you want, but "4" is a string.
For example if you say var num = 5 + "4"; you'll get 54 because 4 is part of a string there, not a integer value.
On the other hand, num = 5 + 4; will give you 9 because they're both integers.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.