Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26709 > unrolled thread

Beginner question: need help assigning multiple variables to a function

Started byJoshua Houston <joshuahouston@gmail.com>
First post2015-01-26 09:46 -0800
Last post2015-01-26 17:24 -0800
Articles 7 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  Beginner question: need help assigning multiple variables to a function Joshua Houston <joshuahouston@gmail.com> - 2015-01-26 09:46 -0800
    Re: Beginner question: need help assigning multiple variables to a function Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-26 11:13 -0800
      Re: Beginner question: need help assigning multiple variables to a function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-26 23:19 +0100
        Re: Beginner question: need help assigning multiple variables to a function Joshua Houston <joshuahouston@gmail.com> - 2015-01-26 17:27 -0800
          Re: Beginner question: need help assigning multiple variables to a function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-27 13:44 +0100
          Re: Beginner question: need help assigning multiple variables to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-29 00:23 +0100
      Re: Beginner question: need help assigning multiple variables to a function Joshua Houston <joshuahouston@gmail.com> - 2015-01-26 17:24 -0800

#26709 — Beginner question: need help assigning multiple variables to a function

FromJoshua Houston <joshuahouston@gmail.com>
Date2015-01-26 09:46 -0800
SubjectBeginner question: need help assigning multiple variables to a function
Message-ID<87163424-a53d-4a60-9564-25162a1650ce@googlegroups.com>
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/3vu82m8g/1/

[toc] | [next] | [standalone]


#26711

FromScott Sauyet <scott.sauyet@gmail.com>
Date2015-01-26 11:13 -0800
Message-ID<6dd97552-fa03-4e52-b1ec-e5621fc64cb8@googlegroups.com>
In reply to#26709
Joshua Houston wrote:
> Can any one please help me with this script? 
> [ ... ] http://jsfiddle.net/Jfact0ry/3vu82m8g/1/

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

[toc] | [prev] | [next] | [standalone]


#26718

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2015-01-26 23:19 +0100
Message-ID<XnsA42EED579A4F7eejj99@194.109.133.246>
In reply to#26711
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/3vu82m8g/1/
> 
> 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)

[toc] | [prev] | [next] | [standalone]


#26724

FromJoshua Houston <joshuahouston@gmail.com>
Date2015-01-26 17:27 -0800
Message-ID<86987572-3972-42ce-ace0-4f0e9d9013d8@googlegroups.com>
In reply to#26718
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/3vu82m8g/1/
> > 
> > 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!

[toc] | [prev] | [next] | [standalone]


#26729

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2015-01-27 13:44 +0100
Message-ID<XnsA42F8BC8680E5eejj99@194.109.133.246>
In reply to#26724
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)

[toc] | [prev] | [next] | [standalone]


#26740

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2015-01-29 00:23 +0100
Message-ID<2063539.c0B48jWhbt@PointedEars.de>
In reply to#26724
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.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#26723

FromJoshua Houston <joshuahouston@gmail.com>
Date2015-01-26 17:24 -0800
Message-ID<3154ddab-8ec8-4bc8-8221-3309fc5580aa@googlegroups.com>
In reply to#26711
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/3vu82m8g/1/
> 
> 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);

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web