Shayne Arnold

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromShayne Arnold
ToMe
SubjectSyntax Errors
Date16 May 2004 10:35
AttachmentFile containing JavaScript code
Dear Sir,


Could you please help me to solve the problem of file above
into the correct format in notepad to answer averages
 
Many Thanks
FromMe
ToShayne Arnold
SubjectRe: javascript syntax errors
Date17 May 2004 08:29
Shayne,

Your errors relate to the way you have written the document.write statement.

You are attempting to concatenate the strings (put them together), but you
have not written the concatenation operator '+'. The line should look like
this:

document.write('Average of '+firstNumber+' and '+secondNumber+' is '+total);


hope this helps


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromShayne Arnold
ToMe
SubjectRe: javascript syntax errors
Date17 May 2004 20:37
AttachmentTest questions and answers
Hi Mark,
             The information you gave me worked,thank you very much for your
help in this matter.At the moment I am doing a Open University course on
computers,this is where the question came from .The tma 03 is a set of
questions that have to be answered and submitted to get
a mark. I have managed the first question and with your help managed part
one of question two, problem is with part c of question two 'How do I
insert fifty stars'.
I am sending down tma03 using winzip for you to look at. I am now working on
Q3.

Once again thankyou for your  support.

Kind Regards Shayne
FromMe
ToShayne Arnold
SubjectRe: javascript syntax errors
Date18 May 2004 10:00
Shayne,

As you may imagine, I do not want to answer your test questions for you,
but I will offer some pointers.

I assume that by 'star' you mean the asterisk character *

You have already used document.write to write content, so I would expect
you to use document.write to write the star.

To do something a number of times, it is usual to use the 'for' loop,
initially seting an index variable to 0, then incrementing it each time,
continuing as long as it is less than the target number.

However, as you would actually use more processor time and more code to do
it this way, you would be better to use just (dots show truncated line)
document.write('*********************** ... *************<br>');

Please note also that your checkString function will not work correctly, as
it uses a return statement during the first loop, so only the first
character is checked. What you should do is return false if it is not
numeric, but do _not_ return true if it is. wait until the for loop has
completed, and _then_ return true. At the moment, the string '1abc' will
return true.

on Q4, consider using
aCharacter = aCharacter.toLowerCase()
to half the number of comparrisons
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.