Framestore interview question

Basic coding question regarding how I would handle the logic