Jump to content

Code Acadamy..Help?


sazaboo

Recommended Posts

Hi,

 

trying to get through the java script learning using Code Acadamy website for an assessment this week, plan was to have a couple of runs through it before the test but my plans have been scuppered by ancient and knackered laptop and unhelpful instructions on the website...

 

so im after anyone who knows the site and knows how to get past a certain point, even when i think ive got the correct code, its not letting me past...

 

its lesson 'Search Text for your name' 4/7

 

my code is...

 

var text " blah blah blah Sarah blah blah Sarah";

var myName "Sarah";

var hits [];

 

for (var i = 0; i < text.length; i++){

if (text === myName [0])

 

and the instructions were...

 

Add your if statement in the body of your for loop. It should check to see whether the current letter is equal to the first letter of your name. (Capitalization counts!)

 

There's no need to put anything between the {}s of your if just yet.

 

 

so the code in red is what ive added for this lesson...its only part completed cause the next lesson adds another 'for' loop.

 

sorry this is a bit random!

 

any help much appreciated!!

Link to comment
Share on other sites

To test if two different things have the same value in JavaScript you use ==. === tests if they are the same actual thing.

 

So if you have three variables defined as:

 

var a = "one";

var b = "one";

var c = a;

 

a == b is true - the values are the same

a === b is false - even though they have the same value they refer to different objects

a === c is true - they refer to the same object

Link to comment
Share on other sites

i think its more of an issue with the tutorial, they have given instructions but the code rquired to get past this bit is in the next section for some reason...theres a forum on the codeacadamy site but its very slow to get a response...but thank you!

Link to comment
Share on other sites

To test if two different things have the same value in JavaScript you use ==. === tests if they are the same actual thing.

 

So if you have three variables defined as:

 

var a = "one";

var b = "one";

var c = a;

 

a == b is true - the values are the same

a === b is false - even though they have the same value they refer to different objects

a === c is true - they refer to the same object

 

a === b is actually true.

 

They aren't string objects; They are string primitives.

 

Proof: https://jsfiddle.net/ydbL860x/

 

---------- Post added 08-04-2015 at 21:17 ----------

 

Sazaboo, can you give us a direct link to the course?

 

Or do you have to sign up?

Edited by John
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.