[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Beginner question: need help assigning multiple variables to a function

Joshua Houston

1/26/2015 5:47:00 PM

Can any one please help me with this script? I'm trying to repeat a function using different parameters. I set a new variable equal to the first one thinking it will run the function. i put in parameters for the second one but I get no results. Thanks. http://jsfiddle.net/Jfact0ry/3...
6 Answers

Scott Sauyet

1/26/2015 7:13:00 PM

0

Joshua Houston wrote:
> Can any one please help me with this script?
> [ ... ] http://jsfiddle.net/Jfact0ry/3...

On this ng, links to code samples are fine, but only as support for
the code you actually post inline. Please post the relevant snippets
here.

-- Scott


Evertjan.

1/26/2015 10:20:00 PM

0

Scott Sauyet <scott.sauyet@gmail.com> wrote on 26 jan 2015 in
comp.lang.javascript:

> Joshua Houston wrote:
>> Can any one please help me with this script?
>> [ ... ] http://jsfiddle.net/Jfact0ry/3...
>
> On this ng, links to code samples are fine, but only as support for
> the code you actually post inline. Please post the relevant snippets
> here.

Indeed.

"assigning a variable to a function"?
Methinks that is neither beginner nor advanced stuff,
it simply does not mean a thing.

btw, why are some people categorizing their questions,
like "beginner's question" [yes, the *'s* should be there, imho]
or "quick question" or even "silly question"?
Is it an equivalent of a shy stutter?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Joshua Houston

1/27/2015 1:24:00 AM

0

On Monday, January 26, 2015 at 10:13:44 AM UTC-9, Scott Sauyet wrote:
> Joshua Houston wrote:
> > Can any one please help me with this script?
> > [ ... ] http://jsfiddle.net/Jfact0ry/3...
>
> On this ng, links to code samples are fine, but only as support for
> the code you actually post inline. Please post the relevant snippets
> here.
>
> -- Scott

Sorry about that. Also, sorry about deleting my post. The code I shared has my Mapbox access id and I realized maybe I don't want to share that.

I solved my problem. My code was fine but when I was trying to add it to the map that killed it. I had already added it to the map in the function.

I now I have
var path = function (person,place) {
var geojson = { type: 'LineString', coordinates: place };
var start = [10, 20];
var momentum = [3, 3];

for (var i = 0; i < 300; i++) {
start[0] += momentum[0];
start[1] += momentum[1];
if (start[1] > 60 || start[1] < -60) momentum[1] *= -1;
if (start[0] > 170 || start[0] < -170) momentum[0] *= -1;
geojson.coordinates.push(start.slice());
}

// Add this generated geojson object to the map.
L.geoJson(geojson, {
opacity: 0
}).addTo(map);

// Create a counter with a value of 0.
var j = 0;

// Create a marker and add it to the map.
var marker = L.marker([0, 0], {
icon: person
}).addTo(map);

tick();
function tick() {
// Set the marker to be at the same point as one
// of the segments or the line.
marker.setLatLng(L.latLng(
geojson.coordinates[j][1],
geojson.coordinates[j][0]));

// Move to the next point of the line
// until `j` reaches the length of the array.
if (++j < geojson.coordinates.length) setTimeout(tick, 600);
}
};
path(barty,seawalk);
path(hagrid,forest);
path(fudge,ministry);

Joshua Houston

1/27/2015 1:28:00 AM

0

On Monday, January 26, 2015 at 1:19:58 PM UTC-9, Evertjan. wrote:
> Scott Sauyet <scott.sauyet@gmail.com> wrote on 26 jan 2015 in
> comp.lang.javascript:
>
> > Joshua Houston wrote:
> >> Can any one please help me with this script?
> >> [ ... ] http://jsfiddle.net/Jfact0ry/3...
> >
> > On this ng, links to code samples are fine, but only as support for
> > the code you actually post inline. Please post the relevant snippets
> > here.
>
> Indeed.
>
> "assigning a variable to a function"?
> Methinks that is neither beginner nor advanced stuff,
> it simply does not mean a thing.
>
> btw, why are some people categorizing their questions,
> like "beginner's question" [yes, the *'s* should be there, imho]
> or "quick question" or even "silly question"?
> Is it an equivalent of a shy stutter?
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

I wrote that I'm a beginner because I want people that don't like dealing with stupid questions to stay away. If someone who isn't understandable of those who aren't familiar with all the proper terms and notations, they might respond with something like, "it simply does not mean a thing. " And I would feel ridiculed by that, so I write "beginner" so you know that I'm a beginner!

Evertjan.

1/27/2015 12:44:00 PM

0

Joshua Houston <joshuahouston@gmail.com> wrote on 27 jan 2015 in
comp.lang.javascript:

> I wrote that I'm a beginner because I want people that don't like
> dealing with stupid questions to stay away.

Questions are never stupid if asked seriously.

Usenet is not a helpdesk, Joshua,
people respond when they feel like it,
and some sometimes like to help.

> If someone who isn't understandable of those who aren't familiar
> with all the proper terms and notations,
> they might respond with something like,
> "it simply does not mean a thing.

Indeed one might.
And one might with rather good reason
when something does not mean a thing.

> "And I would feel ridiculed by that, so I write
> "beginner" so you know that I'm a beginner!

Ridiculing a selfprofessed beginner
is far easier than ridiculing the regulars,
the latter being a nice passtime too.
[come to think of it, you just did, sort of.]

Welcome to usenet.

=====================

A javascript function can have input parameters
in the form of variables and can return a variable.

I fail to see
how you can "assign" a variable to a[n existing] function.

function f(param1, param2) {statements;return returnValue;};

var valueReturned = f(inputParam1, inputParam2);

.... where the variables can also be objects,
and the input variables even litterals,
like litteral numbers or strings.

So if you feel your wording can be improved upon,
to explain what you realy mean, please do so.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Thomas 'PointedEars' Lahn

1/28/2015 11:23:00 PM

0

Joshua Houston wrote:

> I wrote that I'm a beginner because I want people that don't like dealing
> with stupid questions to stay away. If someone who isn't understandable of
> those who aren't familiar with all the proper terms and notations, they
> might respond with something like, "it simply does not mean a thing. "

Completely wrong approach. If you do not want people to read questions they
would consider stupid, simply do not ask questions in a way that you think
is stupid; always ask your questions the smart way. It is easier than you
think, you just have to put your mind into the question. Put yourself into
the position of someone generally willing to help *for free* *in their free
time*, and then choose the wording of the question so that they would want
to read it. If you think of how much *you* value *your* free time, you can
never go wrong.

> And I would feel ridiculed by that, so I write "beginner" so you know that
> I'm a beginner!

We (and I think I am not alone) recognize already from the way that you ask
your question if you are a beginner. And there is nothing wrong with that;
we all have been beginners at some topic at some point in time.

What is wrong is wanting to *stay* a beginner, to have others do your
homework for you, in their free time, for free.

You should read a FAQ for this newsgroup to remove your misconceptions. And
you should not post using Google Groups, which is buggy, and origin of spam
and trolls due to lack of QA there. Use a newsreader instead.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.