You only have free questions left (including this one) .
We're building a web game where everybody wins and we are all friends forever.
It's simple—you click on one of three boxes to see what nice thing you've won. You always win something nice. Because we love you.
Here's what we have so far. Something's going wrong though. Can you tell what it is?
<button id="btn-0">Button 1</button>
<button id="btn-1">Button 2</button>
<button id="btn-2">Button 3</button>
<script type="text/javascript">
const prizes = ['A Unicorn!', 'A Hug!', 'Fresh Laundry!'];
for (var btnNum = 0; btnNum < prizes.length; btnNum++) {
// For each of our buttons, when the user clicks it...
document.getElementById(`btn-${btnNum}`).onclick = () => {
// Tell her what she's won!
alert(prizes[btnNum]);
};
}
</script>
The syntax is just fine—the problem is some unexpected behavior .
Coding style choices aside, what we found is a problem in behavior .
Start your free trial!
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Where do I enter my password?
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
It's easy and quick. No "reset password" flow. No password to forget.
It lets us avoid storing passwords that hackers could access and use to try to log into our users' email or bank accounts.
It makes it harder for one person to share a paid Interview Cake account with multiple people.
Start your free trial!
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Where do I enter my password?
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
It's easy and quick. No "reset password" flow. No password to forget.
It lets us avoid storing passwords that hackers could access and use to try to log into our users' email or bank accounts.
It makes it harder for one person to share a paid Interview Cake account with multiple people.
Start your free trial!
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Where do I enter my password?
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
It's easy and quick. No "reset password" flow. No password to forget.
It lets us avoid storing passwords that hackers could access and use to try to log into our users' email or bank accounts.
It makes it harder for one person to share a paid Interview Cake account with multiple people.
{"id":36593404,"username":"2024-12-27_05:01:18_k5yga#","email":null,"date_joined":"2024-12-27T05:01:18.725480+00:00","first_name":"","last_name":"","full_name":"","short_name":"friend","is_anonymous":true,"is_on_last_question":false,"percent_done":0,"num_questions_done":0,"num_questions_remaining":46,"is_full_access":false,"is_student":false,"first_payment_date":null,"last_payment_date":null,"num_free_questions_left":3,"terms_has_agreed_to_latest":false,"preferred_content_language":"","preferred_editor_language":"","is_staff":false,"auth_providers_human_readable_list":"","num_auth_providers":0,"auth_email":""}
×
“ Interview Cake has been a great resource for me! The weekly questions (and more importantly, the well-explained answers) have prepared me way more than anything else I've done for my interviews. Keep doing what you're doing!
—
Zach
. . .