Weather possible values and Function

Hello everyone, i am newb at this stuff.

What are the possible values ​​for the weather such as Fair, Cloudy, Clear, Rainy etc.?
And how to return the weather for a predetermined location if !weather is entered with no city name and the named city if its used !weather London.( a similar question was there: Weather functionality)
I did as shown here:

$(eval c=$(weather $(query)); $(urlfetch json

I trying:

$(eval c=$(weather $(eval London) : $(query)); $(urlfetch json

But this not work…

Hey @VillsEK!

I don’t know, I guess you can try to cover as much as possible, and if something shows as untranslated at some point then fix it? I know, not ideal, but I don’t really have another solution for you.

If you want to default to a place when no $(query) is specified, we usually do it like this:

$(weather $(eval '$(query)' === '' ? 'DEFAULT_LOCATION' : '$(query)';))

But since you’re including a translation, and if we want to keep it under a single command, I’d do it like this:

$(eval '$(query)' === '' ? w = '$(weather DEFAULT_LOCATION)' : w = '$(weather $(query))'; $(urlfetch json

Note regarding differences between your command and mine: I renamed your c variable as w.
Also, note that I haven’t checked your Pastebin code.

Thank a lot Emily, its work.
One more question, how transofrm from km/h to m/s

Divide the value of km/h by 3.6 to get m/s, if you need further explanation, watch this.

Now, to extract the value and modify it, you’ll need the following bit of code:

Math.floor( (parseInt(w.match(/\d+km\/h/)[0].replace('km/h', '')) / 3.6) * 10) / 10;

This will give you the speed in m/s to a precision of 10^-1 while preventing endless values like 1/3 or 2/3 which would respectively give 0.333...3 and 0.666...6; if you want 10^-2 precision replace both 10 by 100.

Thank Emily. It work too, but parseInt return only number without km/h. I add in my ‘out’ text ‘m/s’.
This is my code:

i hope it will be useful for someone else

1 Like

Yes it does, but if you had anything but a number before the number it’d throw you an error, so it’s good practice to remove anything that could break the code. :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.