AnsweredAssumed Answered

Javascript code issue

Question asked by jasonarnold2721 on Sep 8, 2014
Latest reply on Sep 10, 2014 by samuel.de.rycke
I have a simple javascript that I am having trouble with. It is intended to add a space between a canadian postal code if it finds the courty value to be "CA". The map function first splits the postal code in to 2 sections of 3, then this script runs to piece them back together.

The split function variables are (First) and (Second). 1 for the first 3 characters and 2nd for the next 3 characters. "Zip" is the output.

The script is faulty in that it will always add a space even if the country is "US".



if (Country = 'CA')
{
Zip = (First + ' ' + Second)
}

else

if (Country = 'US')
{
Zip = (First + Second)
}


I also tried it this way


if (Country = 'CA')
{
Zip = (First + ' ' + Second)
}

else

{
Zip = (First + Second)
}

Outcomes