Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2010, 11:03 PM   PM User | #1
georgesofroniou
New Coder

 
Join Date: Nov 2010
Location: Home: Essex, Current Location: Loughborough
Posts: 21
Thanks: 11
Thanked 0 Times in 0 Posts
georgesofroniou is an unknown quantity at this point
Question Help on a Coding Question

Hello,

This is my second post on the forum and I am a coding beginner and therefore relatively new to the forum so sorry for any naive ignorance in the questions I may ask.

I was wondering if anyone could please pass their assisstance regarding a functioning question...?
I am completely stuck and cannot get my head around it on which methods are necessary?!

For this question I think I have to follow the specification pretty regimently, eg. the example result has to include the double quotes around 'prog found in pages 0,3,5,6,9'.

v) function findIdxsC(s) - to return a string containing the indexes in the pages array where s was found in the content part, e.g. "prog found in pages 0,3,5,6,9" [Note that this function will not contain an alert]

Example call: findIdxsC("prog")

Example result: "prog found in pages 0,3,5,6,9"


Cheers, George
georgesofroniou is offline   Reply With Quote
Old 11-09-2010, 11:37 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,211
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Two ways to put quote marks (and apostrophes) inside of a string:
Code:
var one = "Joe said, \"I'm off to see the wizard!\" ";
var two = 'Mary said, "Actually, he\'s just off." ';
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
georgesofroniou (11-10-2010)
Old 11-10-2010, 08:46 AM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Just a thought - does the search for "prog" find whole words only? Or "program", "progressive", "sprog", etc?
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
georgesofroniou (11-11-2010)
Old 11-10-2010, 10:15 AM   PM User | #4
georgesofroniou
New Coder

 
Join Date: Nov 2010
Location: Home: Essex, Current Location: Loughborough
Posts: 21
Thanks: 11
Thanked 0 Times in 0 Posts
georgesofroniou is an unknown quantity at this point
Thanks Old Pedant

*********************

Philip M... from my understanding if you use prog in the search it should find a whole word such as programme.. therefore the result would be: "prog" found.
Hope that answers your question??
georgesofroniou is offline   Reply With Quote
Old 11-10-2010, 11:09 AM   PM User | #5
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by georgesofroniou View Post
Thanks Old Pedant

*********************

Philip M... from my understanding if you use prog in the search it should find a whole word such as programme.. therefore the result would be: "prog" found.
Hope that answers your question??
prog in programme is not a whole word. The whole word is programme. prog is a substring of that word. Example:-

Code:
var mystring = "programme";
if (/prog/gi.test(mystring) {   // true

if (/\bprog\b/gi.test(mystrong)) {  // false
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
georgesofroniou (11-11-2010)
Reply

Bookmarks

Tags
array, function, indexes, javascript, string

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:55 PM.


Advertisement
Log in to turn off these ads.