1
let questions = [
  { question: "Grand Central Terminal, Park Avenue, New York is the world's?", a: "largest railway station", b: "highest railway station",  c:"longest railway statiom", d:"None of the above", answer: "a" },
  { question: "Ttt is the science that studies?", a: "Behavior of human beings", b: "Insects",  c:"The origin and history of technical and scientific terms", d:"The formation of rocks", answer: "b" }         
];

I'm creating a quiz app. It's my questions array. But if the users look to the source, they see answer of all questions. like this

How can i fix that? How to hide datas in the array. İf you help me i will be glad.

1
  • 4
    Serverside validation? E.g. sending the question to the client with answers identified by IDs and sending your answer to the server. This way the answers cannot be viewed by your users at all. Commented May 25, 2021 at 16:31

2 Answers 2

3

You can't hide what's loaded in the browser from the developer console. Your options are:

  1. Obfuscate the answers data. E.g. encode it. But this is still reversible.

  2. Don't load the answers data into the browser until after the user submits an answer. This will require an additional request to the server to fetch the answers.

  3. Don't load the answers data into the browser at all, instead send the user's answers to the server and let the server respond with their score. Again, this requires an additional request to the server.

Sign up to request clarification or add additional context in comments.

Comments

0

<script src="questions.json"></script>

// questions.json
questions = [{"question":"what is your name","ans":"jon skeet"}]

// your javascript file
console.log(questions);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.