• Home
  • Interactive Resume
  • Blog
    • Coding
    • Health & Fitness
    • Success & Lifestyle
  • Contact
  • About

BAOSS

  • Home
  • Interactive Resume
  • Blog
    • Coding
    • Health & Fitness
    • Success & Lifestyle
  • Contact
  • About

Week 11 Day 3 – Code Syntax Like WTF?

Home Coding Week 11 Day 3 – Code Syntax Like WTF?
Week 11 Day 3 – Code Syntax Like WTF?

Week 11 Day 3 – Code Syntax Like WTF?

Apr 6, 2017 | Posted by Bao Le | Coding |

I’m having a hell of a time figuring out this guy’s code. Let me show you some examples:

"computer" == deviceName ? pageVerticalPosition = "internet explorer" == browserName ? 
document.documentElement.scrollTop : pageYOffset : (pageVerticalPosition = pageVerticalPositionOnTouch + 
(touchStartX - touchCurrentX),

This is essentially a ternary nested within a ternary. The first condition checks for the device type, if the device is a computer, it then enters a second conditional. If it isn’t, it sets pageVerticalPosition to the difference between touchStartX and touchCurrentX. When it enters the second conditional, it checks to see whether or not the browser used is Internet Explorer, if it is, it sets pageVerticalPosition to document.documentElement.scrollTop, otherwise, pageYOffset.

After looking at it for awhile, it makes sense, but to have a nested ternary is kinda ridiculous. This shows up on my IDE as one single line… I’m seriously hoping that the code has just been minified.

Here’s some interesting syntax I’ve seen:

if (setLayersMovement(),
    "horizontal" == layersMovement) {

I’ve never seen syntax like this before. What’s happening here is that setLayersMovement() is being invoked first, and then the check for layersMovement is initiated afterwards. I don’t understand why the function couldn’t have been invoked outside of the if conditional as convention dictates, but hey, this works.

One more:

for (; layerHorizontalSpeedArray.length > 0; )
        layerHorizontalSpeedArray.pop();

This is another one I’ve never seen before. The for loop is basically being used as a while loop. Alongside that, there’s no curly braces… how does that even work?

Anyways, this is extremely slow-going, so I’m trudging along best I can.

Now onto some cool stuff!

Yesterday, I had someone from the App Academy cohort immediately after mine, the March cohort, approach me and ask if I was the one with the blog. This was completely unexpected, but a pretty awesome experience. I asked the student for feedback and asked to see how they were enjoying the blog, and received awesome positive responses.

It’s an awesome feeling to know that I’m able to provide some sort of value to the March cohort, and possibly beyond, so if you see me walking around, and want to say hi, please feel free, I’d love to talk to you!

Otherwise, thanks for reading guys, I’ll talk to you tomorrow!

0
Share

About Bao Le

Web Developer at Dropbox. Reach out, I'd love to connect!

Latest Posts

From Bootcamp to Dropbox: Part 2 – Success in the Program

From Bootcamp to Dropbox: Part 2 – Success in the Program

November 27, 2017

Before reading Part 2, make sure you’ve read Part 1!...

From Bootcamp to Dropbox: Part 1 – Application Process

From Bootcamp to Dropbox: Part 1 – Application Process

October 9, 2017

The Decision The decision to go into programming, without...

Signed with Dropbox!

Signed with Dropbox!

September 8, 2017

After a grueling 3 months or so, my job search has come to...

How I Overcome Rejection and Stay Motivated

How I Overcome Rejection and Stay Motivated

July 17, 2017

Having just had my first real rejection from a company I...

How I Overcome Imposter Syndrome Every Single Day

How I Overcome Imposter Syndrome Every Single Day

May 22, 2017

Before I really go into how I personally overcome imposter...

Future Googler

Future Googler

May 2, 2017

I’m finally “finished” with my interactive...

Introducing the Graduate Job Seeker Program

Introducing the Graduate Job Seeker Program

April 26, 2017

I almost forgot to blog today haha. Please expect not as...

Progress on Progress

Progress on Progress

April 25, 2017

The end of Week X Day X titles are here! And with it marks...

Week 13 Day 5 – Google Co-Working Meetup

Week 13 Day 5 – Google Co-Working Meetup

April 24, 2017

The Google meetup was absolutely dope. It was an incredible...

Week 13 Day 4 – Catching Up

Week 13 Day 4 – Catching Up

April 21, 2017

I think I have a pretty solid game plan of how to attack my...

Contact Us

We're currently offline. Send us an email and we'll get back to you, asap.

Send Message

Let’s Connect!

© 2025 · imbaoss.com

  • Facebook
  • Twitter
  • Instagram
  • LinkedIn
  • GitHub
Prev Next