Help with ternary statement

Made some progress, turns out a big part of the issue was the timing and loading. I was using autoload, had to stop using that because it seemed to pull before the data from the other record sets were available even though I could see they loaded in the correct order in the browser.
Patrick that bit about the length formatter not working on numbers also turned out to be apart of the issue.
Thanks for all your help everyone.