Program

function ListItem(props) {

  return <li>{props.value}</li&g">

MCQs > IT & Programming > React.js >

Which of the following code snippets should be there in place of "???" in the below given program so that the following output is printed on the console?

Program

function ListItem(props) {

  return <li>{props.value}</li>;

}

function NList(props) {

  const numbers = props.numbers;

  return (

   <ul>

???

   </ul>

  );

}

const numbers = [8, 6, 4, 2, 1];

ReactDOM.render(

  <NList numbers={numbers} />,

  document.getElementById('root')

);

Output

•  8

•  6

•  4

•  2

•  1


React.js MCQs

Which of the following code snippets should be there in place of "???" in the below given program so that the following output is printed on the console?

Program

function ListItem(props) {

  return <li>{props.value}</li>;

}

function NList(props) {

  const numbers = props.numbers;

  return (

   <ul>

???

   </ul>

  );

}

const numbers = [8, 6, 4, 2, 1];

ReactDOM.render(

  <NList numbers={numbers} />,

  document.getElementById('root')

);

Output

•  8

•  6

•  4

•  2

•  1


Answer

Correct Answer:

{numbers.map((number) =>

    <ListItem key={number.toString()}

            value={number} />

  )} 

Explanation:

Note: This Question is unanswered, help us to find answer for this one

React.js Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

React.js Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it