0

I have a quiz like this enter image description here

The problem is $x^2$. I want to make a math equation. $x^2$ should be x power 2. this is the js code

const quizdata = [{
  question: "$x^2$ Characterized by skill at understanding and profiting by circumstances",
  options: ["Prescient", "Analyst", "Diminution", "Shrewd"],
  answer: "Shrewd",
  category: 1
}],

is there a way to display math equation for this case?

fjc
  • 5,590
  • 17
  • 36
Eddy
  • 35
  • 8
  • 1
    Welcome to Stackoverflow! What have you tried so far to solve this? Where have you failed? You'll normally have more success getting good answers here if you attempt to find a solution yourself, and not ask for a generic "how do I solve this" tutorial – fjc Aug 25 '20 at 09:52
  • 1
    Does this answer your question? [What's the best way to write Mathematical Equations on the Web?](https://stackoverflow.com/questions/796890/whats-the-best-way-to-write-mathematical-equations-on-the-web) – MrProgrammer Aug 25 '20 at 10:01

4 Answers4

1

The formatting of your formula looks like TeX. You can either rewrite simple stuff using HTML, e.g.

2<sup>2</sup>

to achieve 22

Or use tools like https://www.mathjax.org/ for displaying complex math.

Eriks Klotins
  • 4,042
  • 1
  • 12
  • 26
1

Include MathJax lib, for generating nice Latex-based math formulas

<html>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
$$ y=x^2 $$
<html>
Agnius Vasiliauskas
  • 10,935
  • 5
  • 50
  • 70
0

Yes, you have to use HTML tag sup for that:

x<sup>2</sup> will display x2

Justinas
  • 41,402
  • 5
  • 66
  • 96
0

You can print the math equation the way you want using the ascii math method.

Etc web site. http://asciimath.org/