Javascript

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJavascript

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old September 22nd, 2011, 04:32 PM
webdorq webdorq is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 1 webdorq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 52 sec
Reputation Power: 0
Help a newb

I am trying to work through a tutorial at codecademy and am stuck on this exercise.
Code:
// Examples of using indexOf. // 3. 'foobar'.indexOf('bar');  // -1 'foobar'.indexOf('baz');   // Modify the following function according to the comments inside // This function will be tested for correctness using a set of  // example inputs  function contains(str, substr) {      // modify this code to return true if substr is a substring of str   // and false if substr is not a substring of str    var include = 'str'.indexOf('substr');   if (include < 0) {   print('false'); } else {   print('true');    };       }
The output looks correct, but they seem to be looking for something else.

Reply With Quote
  #2  
Old August 22nd, 2012, 07:34 PM
jardrake jardrake is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 2 jardrake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 28 sec
Reputation Power: 0
That formatting isn't really great to read because of this I cannot read it to see your problem.

First, I know you are doing codeacademy, but 'footer'.method is never going to get you anything. Perhaps, they are trying to demonstrate that it is a String method, but that is a terrible way to do it.

You are using the string .indexOf method. Maybe googling for the methods will help solve your problem

Hope this helps!

Reply With Quote
  #3  
Old January 22nd, 2014, 10:49 AM
grsl grsl is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2014
Posts: 4 grsl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 18 sec
Reputation Power: 0
You are printing the string 'true' or 'false' not returning true or false as a boolean type. i.e. The return value can be evaluated in an if statement.

i.e.

return subStr(str, subString);

Where subStr returns true or false and not 'true' or 'false'.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJavascript > Help a newb


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap