The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> code to return Calm is now wind., I need help figuring out this code.
John Zapf
post Jun 5 2020, 07:29 PM
Post #1





Group: Members
Posts: 3
Joined: 5-June 20
Member No.: 27,379



If I use this code it returns wind speed. if the wind speed is 0 it returns Calm - perfect.

<div>${ob.windSpeedMPH> 0 ? `${ob.windSpeedMPH}mph` : `Calm`}</div>


But I want to add the wind direction to the output, this works for that. Returns wind direction and speed, ie. SSW@4mph - BUT if the wind is 0 it returns SSW@calm. This is what I need help with. If the wind is 0 I want it to return Calm for both the wind direction and wind speed, just one word, Calm. can you tell me how to accomplish this with the below code?

<div>${ob.windDir || 'N/A'}@${ob.windSpeedMPH> 0 ? `${ob.windSpeedMPH}mph` : `Calm`}</div>


Thanks, John
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jun 5 2020, 08:54 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Well, just move it.
CODE
<div>${ob.windSpeedMPH} > 0 ? `${ob.windDir || 'N/A'}@${ob.windSpeedMPH}mph` : `Calm`}</div>

I'm not sure those smart single quotes will work.

This post has been edited by CharlesEF: Jun 5 2020, 08:57 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
John Zapf
post Jun 5 2020, 09:12 PM
Post #3





Group: Members
Posts: 3
Joined: 5-June 20
Member No.: 27,379



ok, we will see, next time its Calm

This post has been edited by John Zapf: Jun 5 2020, 09:50 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jun 6 2020, 01:05 AM
Post #4


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



If there's something you don't understand, just ask.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
John Zapf
post Jun 6 2020, 08:37 AM
Post #5





Group: Members
Posts: 3
Joined: 5-June 20
Member No.: 27,379



this is what ended up working. thank you for your help.

<div>${ob.windSpeedMPH> 0 ? `${ob.windDir}&nbsp@&nbsp${ob.windSpeedMPH}mph` : `Calm`}</div>

This post has been edited by John Zapf: Jun 6 2020, 09:36 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jun 6 2020, 02:36 PM
Post #6


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Glad you got it working but '&nbsp' is missing the ending semi-colon.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th March 2024 - 11:27 PM