If/Else Statement with JavaScript Code

  • 26 February 2022
  • 1 reply
  • 982 views
If/Else Statement with JavaScript Code
Userlevel 7
Badge +14

📌  We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy users.

 

About

Used to create conditional logic that is evaluated based on inputs.

 

How to Configure

 

Copy the Code

let Hour = inputData.Hour; // 0-23 for a 24 hour clock; 0 = 12 AM, 12 = 12 PM

let AMPM = ""; // sets a blank value
if (Hour < 12) {
AMPM = "AM"; // sets AM if value is less than 12
}
else {
AMPM = "PM"; // sets PM if NOT AM (aka a value equal to or greater than 12)
}

output = [{Hour, AMPM}];

 

The Results

 

Contribution by Troy Tessalone

Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.


1 reply

Userlevel 4
Badge +1

Love these @Troy Tessalone — Keep ‘em coming, as they can be really be useful! Have a nice weekend!

Reply