An N or not a N

I

Ivo

Consider a simple onkeypress script that alerts with messages like
"You typed a A!"
I have written a small function that considers when it should be
"You typed an A!"
where the variable string is preceded by "an" rather than "a", and would
appreciate comments, since English is not my mother language and I
don't know exactly when you say "an" rather than "a". If I feed whole
words to this function, is a test for the first letter enough?

function atrailn(n,u){
var a = ['a','e','f','h','i','l','m','n','r','s','x','8','11','18','80' ];
if( typeof n==='string' ){ n=n.charAt(0); }
return
( u ? 'A' : 'a' ) +
( in_array( (''+n).toLowerCase() , a ) ? 'n' : '' ) +
' ' + n;
}

function in_array(n,a){
var i=a.length; while(i--){ if(a===n){ return true; } } return false;
}

function alertletter(n){
alert( 'That was ' + atrailn(n) + '.' );
}
 
R

RobG

Ivo wrote:
[snip]
appreciate comments, since English is not my mother language and I
don't know exactly when you say "an" rather than "a". If I feed whole
words to this function, is a test for the first letter enough?
[snip]

Not really a JavaScript question, perhaps you should try
microsoft.public.word.spelling.grammar. Anyhow, here is a
site that gives some pointers:

http://owl.english.purdue.edu/handouts/esl/eslart.html

It is a US institution (Purdue), however it should be OK.
The main thing is that it is the *sound* that is important,
not the actual letter.

e.g. 1. Some people may say "an historical perspective",
others "a historical perspective". H is not a vowel, but it
sounds like one in the above context so many people say "an"
rather than "a".

e.g. 2. "one" starts with a vowel, but most would say "a one
hundred percent chance", not "an one hundred..." because
"one" sounds like it starts with a consonant (i.e."w" as in
won) so it gets "a" not "an".

As you have noticed, you will have to convert number to
words, then test the words. But there are many exceptions
and many more examples I'm sure.

Cheers, Fred
 
P

Philip Ronan

Consider a simple onkeypress script that alerts with messages like
"You typed a A!"
I have written a small function that considers when it should be
"You typed an A!"
where the variable string is preceded by "an" rather than "a", and would
appreciate comments, since English is not my mother language and I
don't know exactly when you say "an" rather than "a".

Use "an" for A, E, F, H, I, L, M, N, O, R, S and X. Use "a" for all the
other letters of the alphabet. (Yes, that includes "u"!)
If I feed whole
words to this function, is a test for the first letter enough?

No. This is actually very difficult to do. Take a look at:
<http://www.faqts.com/knowledge_base/entry/edit/index.phtml?aid=26340>

Phil
 
R

Randy Webb

Philip said:
Use "an" for A, E, F, H, I, L, M, N, O, R, S and X. Use "a" for all the
other letters of the alphabet. (Yes, that includes "u"!)

Not sure where you got those rules from, but of the 13 you list, I know
at least 10 do not fit the rule you provide.

H is an exception to the consonant rule. If a word begins with a
consonant, then it uses "a", not "an". X or maybe Q would be an exception.

The difficulty comes with words that begin with a vowel (including
sometimes Y), where its not spelling determined, but phonetically
determined.
 
L

Lee

Philip Ronan said:
Use "an" for A, E, F, H, I, L, M, N, O, R, S and X. Use "a" for all the
other letters of the alphabet. (Yes, that includes "u"!)

In US English:

An hour
A hair

An onion
A one-horse town

An uncle
A union

An x-ray
A xylophone

An yttrium atom (the only example I can think of for "an y*".
A yak

I can't think of any examples of:

an F*
an L*
an M*
an N*
an R*
an S*

other than when saying the names of the letters, as in:
"Gimme an 'F'!"
 
P

Philip Ronan

Not sure where you got those rules from, but of the 13 you list, I know
at least 10 do not fit the rule you provide.

I was referring to the individual letters, not words that *begin* with those
letters (which is what the OP was referring to in the text I originally
quoted).

I also gave the URL of a web page that explains the problems of applying
this to whole words (which is what the OP was referring to in the second bit
of text I originally quoted).

Here's another URL for you: <http://www.sniffles.ca/wavs/raspberry.wav> :p
 
R

RobG

Lee said:
other than when saying the names of the letters, as in:
"Gimme an 'F'!"

That's exactly what Phil meant, because that is what the OP
asked for. He asked how to tell whether to put "a" or "an"
in front of single letters. Then the OP asked if this same
rule applies to words.

Phil's answer is correct on both counts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top