Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

29 lines
810 B
Markdown

---
title: Use Advanced JavaScript in React Render Method
---
# Use Advanced JavaScript in React Render Method
---
## Problem Explanation
While you are inside the render method and not inside the return method, you can write JavaScript **without** wrapping it inside curly braces.
First, you will have to set the constant 'answer' to a value. Access the 'possibleAnswers' array using the value of 'randomIndex', which is located within the state of your component. Remember, you access state using `this.state`.
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
```js
const answer = possibleAnswers[this.state.randomIndex];
```
Next, insert your const 'answer' into the p-tags. Make sure to wrap it with curly braces `{ }`.
```jsx
<p>
{answer}
</p>
```
</details>