Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2013, 10:34 AM   PM User | #1
hafizrashid
New to the CF scene

 
Join Date: Jan 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
hafizrashid is an unknown quantity at this point
sick to complete this code

hi there.

anyone can help me to complete this

3. The following Javascript function, while grammatically correct, is sometimes unreliable. It is to be deprecated and you have been tasked to create a new function. It should accept an array parameter and assign each element in the array value to the supplied input value. If input array is a multi dimensional array it should reset the children elements as well.

function myresetter_func (counter, arr1, str)
{
i = q = counter = 0;
temp = arr1;

for (var i=0;i<temp.length;i++){
if(temp[i].length > 0)
{
for (q=0;q<temp[i].length;q++)
{
temp[i][q] = str;
}
} else
temp[i] = str;
}
return temp;
}
hafizrashid is offline   Reply With Quote
Old 01-17-2013, 12:56 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Show the code that you have written so far.

As a general rule, the people helping out in this forum don't write code for others (especially code that appears to be for homework), but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

It is recommended that you place the opening brace following the function, if, else, for, while, do, switch, and try statements on the same line and not on the following line. Apart from that every Javascript statement should be followed by a semi-colon (;). It is quite possible to disregard this advice, but if you do one day it will rise up and bite you in the undercarriage.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 01-17-2013 at 12:58 PM..
Philip M is offline   Reply With Quote
Old 01-17-2013, 02:11 PM   PM User | #3
Airblader
Regular Coder

 
Join Date: Jan 2013
Location: Germany
Posts: 368
Thanks: 3
Thanked 44 Times in 44 Posts
Airblader can only hope to improve
Additionally you should want to do it on your own rather than have someone else do it. Because if you don't give a damn about learning this, drop whatever you're doing and pick another career, something you're willing to learn.

The IT business has already more than enough retards who somehow cheated their way through college to get a good job. I deal with them every day.

air
Airblader is offline   Reply With Quote
Old 01-17-2013, 09:49 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,247
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I sure hope this is just a wrong translation from the original language into English:
Quote:
assign each element in the array value to the supplied input value.
That would say "none of the array element values are changed; instead they are assigned one at a time to the input variable [which doesn't exist, but that's another problem] ." The result of course would be that input would contain the value of the last array element found. But since the problem doesn't specify the *order* in which the array elements are to be traversed, that means you could assign the value of any array element to input and be correct.

Clearly the sentence SHOULD read:
Quote:
assign the value of the argument named str to each element of the array argument named arr1
__________________
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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:24 AM.


Advertisement
Log in to turn off these ads.