[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I don't understand, what the fuck did I do wrong?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 37
Thread images: 2
File: Untitled.png (137 KB, 1600x900) Image search: [Google]
Untitled.png
137 KB, 1600x900
I don't understand, what the fuck did I do wrong?
>>
>>53478377
I asume you are a nigger
Try a diffrent name
>>
>>53478410
I'm white, my mother is retarded. But it says the "{" was an unexpected token, how is it in the wrong place? What am I doing incorrectly?
>>
>>53478424
you might want to look at the syntax for if/else statements again mate
>>
your syntax is messed up

if (myname.length === 6)
{
stuff();
}
else
{
differentstuff();
}
>>
===what is wrong with this?===
>>
>>53478448
Oh I see, so I just needed to move my string up one. Is the ";" important to syntax?
>>
>codecademy

don't use this, it's shit
>>
>>53478462
i don't think the semicolon is required in javascript, but it's good practice to put it after every statement.
>>
>>53478462
Yep.
>>
>>53478472
I don't know what else to use, tried reading books but I'm truly retarded. I'm really fucking lost. I don't know how you fucks do it.
>>
>>53478487
When I put it in after the if statement it said incorrect syntax, how does the semicolon effect the string?
>>
>>53478491
just finish your codeacademy course, then go through a book like eloquent javascript (which is free online).
>>
>>53478508
Awesome, thanks for your help. I'm hoping this will all come together soon because it's still gibberish to me.
>>
I did a few courses on Codecademy, it's notorious for giving you errors EVEN if you have the right answer. Sometimes you can cut the code, reload, and paste and it will take the answer you just cut!

Codecademy's lessons are spotty at best.
>>
>>53478491
syntax is either

if (condition)
statement();


or

if (condition)
{
statements();
statements();
statements();
}


by putting the semicolon immediately after you are doing

if (condition)
;


which tells it to do nothing if the condition is met.
>>
>>53478505
The semi-colon basically means "this is the end of this statement". Most languages require it so it's definitely a worthwhile habit to get into.

You DON'T need a semi-colon after the if (...), else, {, }, or other control structures. Your variable declaration at the top and your console.log() calls should end in semi-colons.
>>
File: Untitled.png (186 KB, 1600x900) Image search: [Google]
Untitled.png
186 KB, 1600x900
NOW what did I do wrong? They all work perfectly, and I did include a no option.
>>
>>53478876
Recheck it again
>>
>>53478975
I've been staring at it for 5 minutes, I really don't understand where I went wrong.
>>
>>53478986
line 13 and not using else if
>>
It always excites me seeing someone first beginning to learn to program and actually taking a proactive approach to problem solving, instead of just "this is too hard i give up lol"
>>
Give it back, Jerome
>>
>>53478876
You ended the if statement with a }
You should have done

If {
Something
Something
Else
Something
Something
}

I think that's the problem . its 3 am here and I'm tired
>>
>>53479991
Also depending on the language you might or not need to open and close bracket after a conditional or a for.

Example

For i=0,I<10,I++
Do something

Might be enough sine you only have 1 line after the for.

Other languages are more strict and will mark the above structure as invalidad . it is also true the other way around where some languages will not accept brackets after a for if you only have 1 line
>>
>Windows 10
Found the problem
>>
>>53478377
Is this the famous Windows font rendering?

Don't use Codecademy, you wont learn anything, read a book or watch a lecture.
>>
Nobody has ever made anything of lasting worth in javascript.

Nothing but bay area hipsters remaking existing applications with more "modern, dynamic, responsive UX born from the browser and advanced web technology" as far as the eye can see. With obligatory sciencey-looking logos and names to make them look like trv nerds, of course.

Give up now and go take a C++ class with actual tutors and instructors
>>
Remove the semicolon after the if statement. If you keep it, the if will do nothing, because what you wrote is this:

If myName.length == 6, then stop.

The curly brackets after the if are just decoration and the code inside will always run regardless of whether the if returned true or false, because the if is not connected to the curly brackets below it.
>>
im maybe wrong but you should use == instead of === on the 14th and the 18th line.because you are not looking for the length of the atring but rather the actual string "yes" and "no"
>>
because you wrote in javascript
>>
>>53479991
in javascript it is

if(a === "no"){
code();
} else if(a === "yes" {
code();
} else {
code();
}


>>53480677
nothing wrong with ===
>>
>>53478462
You should put the statement to check before {, and your lines of code should end with ;
>>
>>53478377
you got 1 too many ; nigga
>>
>>53480419
The guy can't even properly create an if statement and you think he should jump in to c++?
>>
>>53479726
Would you say you're easily excited, generally speaking?
>>
OP here, thanks so much for everyones help /g/. Im still clueless in general about what im soing but im going to keep at it, and ill take some Uni classes next semester. Hopefully it starts to make sense soon.
Thread replies: 37
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.