Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Hiding answers in javascript Quiz script

Hi people. I wonder how do I need to hide answer for questions made with javascript? Because its easy to find answers in source code.

Tsenko Aleksiev
Tsenko Aleksiev
3,819 Points

I think....I don't understand. Can you please clarify a bit? :)

Justin Deardorff
Justin Deardorff
8,448 Points

If you want to completely obscure it you would typically retrieve it from a back-end server or database on request instead of storing it directly in client-side javascript. There are steps you can take to obscure your javascript a bit but if it's on the client side it will always be able to be found.

Justin, so there is no other way I can store them safe and they wont be found without using back-end?

Tsenko. If you make Quiz script with javascript where is questions and answers. User will mark in website which one is answer and later it will show how many correct answers and how many not. But if you make quiz with javascript, you need to make questions and give them right answers. In source code, if you go to fx: treehouse . com/questions.js there you can find all answers in javascript file.