Client Security Hash - String Manipulation - Array - Space in Country

Good morning beautiful people,

I’m running through the Client Security Hash exercise. I’ve completed it but when I upload it for testing, I’m getting a 0/100. I think this is due to there being a space inside my hash formula.
10-12-2019%209-28-24%20AM
As you can see above, Client ID and Name come through just fine. But Country is failing with that darn space. Any help with this would be great.



Hey @BotMonkey

In your invoke workflow for generate hash god, under in_HashFormula input argument you are passing the combination. In there, just add a trim to the ClientCountry. It will solve the problem.

ClientID + "-" + ClientName + "-" + ClientCountry.Trim

2 Likes

Worked like a charm. Thank you. Can you explain why it wouldn’t do that in the initialization of the array? It did for the first two? Why not country?

1 Like

It is because of this… Have a look

See the two parts I highlighted in red and blue?

First take the red colored part
Here, TempID(2) contains some string. And you add a Trim to that. This will remove the spaces in front and at the end of the string. But will not really remove the spaces in between.
Example
" Country Name: Alaska "
Your trim here will make this string like this
“Country Name: Alaska”

Now get to the blue part.

Here you split that trimmed string again by the “:” character and you take the second element
So this is what happens when you split

1st element
“Country Name”
" Alaska"
You see, when split by that character, you actually have a space after that character. That’s why you are getting that space there.

So your code should be changed a bit like this
tempid(2).Trim.Split(":"c)(1).ToString.Trim

This will work too. :slight_smile:

1 Like

Thank you so much for this! Being able to understand something is so much better than just inserting some code that works. Again, thank you. You’ve made someone a better code monkey today :slight_smile:

1 Like

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