generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: JavaScript, only if you know..

Previous Thread :: Next Thread 
sentry3 is not online. sentry3
Joined: 01 May 2010
Total Posts: 538
31 Jul 2016 02:32 AM
I know this is maybe not the place for this but there is a lot of smart people here so,

im trying to find a name in a variable

//sentence

var text = 'hello my name is Nick, to bad your \
name is not Nick';

//my name

var myName = 'Nick';

//array

var hits = [];

for (var i = 0; i < text.length; i++){
if (text[i] === myName){
for (var j = i; j + myName.length; j++){
hits.push(myName[j]);
}
}
}



basically the error says
'It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.'
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Jul 2016 02:41 AM
you put ' j + myName.length' instead of j < myName.length'
Report Abuse
sentry3 is not online. sentry3
Joined: 01 May 2010
Total Posts: 538
31 Jul 2016 03:21 AM
@Flux

Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
31 Jul 2016 03:33 AM
it will still never stop because any non-0 integer evaluates to true.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image