Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Studying for JavaScript test, NEED HELP!!!

  • 16-04-2013 1:20pm
    #1
    Closed Accounts Posts: 7


    Hello,

    Well my university exams are coming up in mid May and I am starting to study JavaScript. I am reading past exam questions and online tutorials. I have a problem though, that I came across today. Here is a picture of the question. Somebody please help me. Thanks!

    20130416_141148.jpg


Comments

  • Registered Users, Registered Users 2 Posts: 931 ✭✭✭aperture_nuig


    hellomott0 wrote: »
    Hello,

    Well my university exams are coming up in mid May and I am starting to study JavaScript. I am reading past exam questions and online tutorials. I have a problem though, that I came across today. Here is a picture of the question. Somebody please help me. Thanks!

    20130416_141148.jpg

    Can you tell us where you are having the problem specifically?


  • Closed Accounts Posts: 7 hellomott0


    I am mostly having problems with the code to test for letter "a" and "e".


    I know that for example:

    var hello = /^ [a-zA-Z] /;


    ..that shows what letters you can enter..that's as far as it goes.

    Thanks..


  • Registered Users, Registered Users 2 Posts: 242 ✭✭MeTV


    You could just loop through the string one character at a time, check what each character is and increment a variable if it's one of the letters you're looking for.


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    And if you don't know how to do that -> http://www.quirksmode.org/js/strings.html#charat


  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    var matches = myString.match(/e/gi);
    alert(matches.length);

    matches can be null, so you'll have to handle that.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 626 ✭✭✭Cork Boy


    OP, do you mind if I ask what course you are doing and what year you're in? I'm self studying and would love to know what level I'm at relative to a real college...

    Cheers


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Work out how to solve the Fizz Buzz problem and this will be plain sailing to you.


Advertisement