Learn ReactJS - The ternary operator 11/16

Hi! Can someone help me?

The instruction is:
On line 14, replace x, y, and z with the following three expressions. You have to decide which is x, which is y, and which is z:



coinToss() === 'heads’
’heads’ should return ‘kitty’, and ‘tails’ should return ‘doggy’.

Error message is:
Your ternary operator should look like coinToss() == ‘heads’ ? ‘kitty’ : 'doggy’


import React from 'react';
import ReactDOM from 'react-dom';

function coinToss () {
  // Randomly return either 'heads' or 'tails'.
  return Math.random() < 0.5 ? 'heads' : 'tails';

const pics = {
  kitty: 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-kitty.jpg',
  doggy: 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-puppy.jpeg'

const img = <img src={pics[coinTos() === 'heads' ? 'kitty' : 'doggy']} />;


in this line:

const img = <img src={pics[coinTos() === 'heads' ? 'kitty' : 'doggy']} />;

you misspelled coinToss, so javascript/react attempts to call a non-existing function, that doesn’t work

1 Like

I was searching for a more complicate error and it was really simple. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.