Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2010
    Location
    Home: Essex, Current Location: Loughborough
    Posts
    21
    Thanks
    11
    Thanked 0 Times in 0 Posts

    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

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    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.

  • Users who have thanked Old Pedant for this post:

    georgesofroniou (11-10-2010)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,992
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Just a thought - does the search for "prog" find whole words only? Or "program", "progressive", "sprog", etc?

  • Users who have thanked Philip M for this post:

    georgesofroniou (11-11-2010)

  • #4
    New Coder
    Join Date
    Nov 2010
    Location
    Home: Essex, Current Location: Loughborough
    Posts
    21
    Thanks
    11
    Thanked 0 Times in 0 Posts
    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??

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,992
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    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

  • Users who have thanked Philip M for this post:

    georgesofroniou (11-11-2010)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •