Re: js Newbie

From: ilir hoti (ihoti2001_at_ntlworld.com)
Date: 07/18/04


Date: Sun, 18 Jul 2004 08:09:50 GMT

Steve van Dongen [MSFT] wrote:

> On Sat, 17 Jul 2004 18:43:20 GMT, ilir hoti <ihoti2001@ntlworld.com>
> wrote:
>
>
>>Lee wrote:
>>
>>
>>>ilir hoti said:
>>>
>>>
>>>>Hi guys
>>>>having great difficulty with figuring out the dropVowels functionneed
>>>>some urgent help, please, thanks in advance.
>>>>here is my code
>>>
>>>>any suggestions would be greatly anticipated,
>>>
>>>I suggest you drop the class.
>
>
> Altough in the end it may in fact turn out to be a good suggestion,
> lets not be hasty. :)
>
>
>>OK first of all I guess you are pretty good at JS, yes you are absolutly
>>right i did copy some of the code.
>>But I would appreciate if you could give me some help instead of having
>>a go. No doubt that you were once a complete novice, unless you were
>>born with the talent of programming. And as such you will appreciate
>>that i am finding it very difficult to come up with an answer to this
>>particular question. so i made the effort for a good few hours today and
>>wrote my own code. Here it goes:
>
>
> You will find that most people can fairly easily spot homework-style
> problems, having also done them at some point in their lives, and will
> generally opt to either ignore the post completely or will offer hints
> rather than simply providing a complete, working solution.
>
> Ironically, if this is indeed a homework question, it's a really bad
> one considering you can delete all the vowels with one built-in
> function call.
>
> Anyways...
>
>
>>function dropVowel(aCharacter)
>>{
>>var aCharacter = vowelString['a','A','e','E','i','I','o','O','u','U']
>>}
>
>
> Here there is a funtion that is presumably the function that you are
> asking for help writing, yet it is never called and effectively does
> nothing. All it does is create and (incorrectly) initialize a local
> variable.
>
>
>>var resultString='';
>>var inputString = window.prompt('enter your string here', '');
>>var vowelString= ['a','e','i','o','u','A','E','I','O','U'];
>>var position='';
>>{
>>for (var position=0; position<resultString; resultString=position+1);
>
>
> for statement
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsstmfor.asp
>
> Consider what this loop does...
> 1. Initialize position=0
> 2. Compare position ( 0 ) < resultString ( '' ). What is the logical
> result of testing whether 0 is less than an empty string?
> 3. Assuming the above test evaluates to false, resultString is set to
> position+1 ( 1 )
> 4. Note that your for statement ends in a ; meaning that there are no
> statements executed on each loop iteration.
>
>
>>}
>>if (inputString!=vowelString)
>>{
>>document.write(inputString != vowelString + '<BR>'+ resultString)
>>}
>
>
>>I know this is so wrong, but could you point out where i am going wrong.
>
>
> Where you are going wrong is not first thinking about what you are
> trying to accompish. You have to think about the problem and break
> the it up into smaller pieces. People who cannot think about and
> understand the problem cannot write a program to solve it.
>
> When I interview people, I am primarily looking for problem solvers.
> If you happen to be write code proficiently in the languages we use,
> great, but if not then I don't kick you out the door and there is
> still a chance you will get hired. Good programmers can learn new
> languages without much difficulty. Learing problem solving and the
> thinking processes involved *before* writing code is much more
> difficult. In fact I have heard some people claim that these skills
> actually cannot be taught -- that it comes naturally to people who
> turn out to be good programmers.
>
> First, define the problem. You never really said what you are trying
> to do, but I deduce that the problem is --
> Delete all the vowels from a string.
>
> Then think about how you do that --
> Check whether each character is a vowel, and if it is, delete it.
>
> Then start writing psuedo-code for the logic --
> prompt for a string
> loop through each character in the string
> if the current character is a vowel...
> delete the current character from the string
> display the result
>
> At this point, you might look at the psuedo-code above and think, "How
> do I know if the current character is a vowel?" followed by "That
> would probably be a good thing to have a function for". Then you
> would start writing psuedo code for that --
> function IsVowel ( takes a character as an input parameter)
> if the character is a, e, i, o, or u then it is a vowel
> otherwise it is not
>
> Now, the entire problem is solved. Up until this point you have
> simply been planning and thinking about what you are trying to
> accomplish. As you start to write the program you will have to start
> thinking about language-specific details. For example, lets say you
> were writing the code for this step --
> delete the current character from the string
> If you were writing the code in C++ you would likely not literally
> "delete a character from the string". Instead, you would loop through
> the string, copying non-vowel characters overtop of vowel characters,
> and then terminate the string. Likewise, if you were implementing
> this in JScript (which you are obviously), you would probably loop
> through the string, copying non-vowel character overtop of vowel
> characters, and then (because you cannot terminate a string like you
> can in C++) copy the substring of characters you want to keep to a new
> string.
>
> Hopefully by now I've given you enough to think about.
>
> JScript Fundamentals
> http://msdn.microsoft.com/library/en-us/script56/html/js56jsconjscriptfundamentals.asp
>
> Regards,
> Steve
> --
> Please post questions to the newsgroup; everyone benefits.
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Sample code subject to http://www.microsoft.com/info/cpyright.htm
Thank you very much, Steve.
in any other circumstance i would follow the logical path to solving a
problem. but in programming i get stuck. maybe this is because i have
not read all the literature as i should have done and give myself enough
time to prepare. but thank you very much again. it all makes sense now
Regards,
Ilir



Relevant Pages

  • Re: js Newbie
    ... asking for help writing, yet it is never called and effectively does ... Delete all the vowels from a string. ... Check whether each character is a vowel, and if it is, delete it. ...
    (microsoft.public.scripting.jscript)
  • Re: Check for Common character sequence ( I will pay)?
    ... Dude, programming is all problem-solving. ... You need to identify character sequences of 3 or more characters that appear ... in more than one string. ... and test each 3-character sequence that results. ...
    (microsoft.public.dotnet.framework)
  • Re: searching for the highest index within a directory
    ... (I used to write code in the Ada programming language... ... Because "testFile_34" is a string, ... there is no way to compare them as numbers. ... means we look at the first character in each string. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: safe strcpy()?
    ... Programming and be paranoid about everything...unless you meant ... For each character in a printable string, I check whether it needs to be ... I stop copying and send the buffer ...
    (SecProg)
  • Input statement question
    ... I'm still new at Python and have been away from programming for a ... inputshould get a standard string as the default ... The new line character could be the default termination character, ... format is a regular expression string ...
    (comp.lang.python)