-1

Here is the code

dowl.define('owl').then(function(result){
   console.log(result)
  
})

It returns

{ definitions:
   [ { type: 'noun',
       definition:
        'a nocturnal bird of prey with large eyes, a facial disc, a hooked beak, and typically a loud hooting call.',
       example:
        'I love reaching out into that absolute silence, when you can hear the owl or the wind.',
       image_url:
        'https://media.owlbot.info/dictionary/images/owl.jpg.400x400_q85_box-403,83,960,640_crop_detail.jpg',
       emoji: '' } ],
  word: 'owl',
  pronunciation: 'oul' }

How do I get the definition of the word?

I tried result.definitions

and it returns

 [ { type: 'noun',
       definition:
        'a nocturnal bird of prey with large eyes, a facial disc, a hooked beak, and typically a loud hooting call.',
       example:
        'I love reaching out into that absolute silence, when you can hear the owl or the wind.',
       image_url:
        'https://media.owlbot.info/dictionary/images/owl.jpg.400x400_q85_box-403,83,960,640_crop_detail.jpg',
       emoji: '' } ]

I tried result.definitions.definition

It doesn't do anything. How do I get the definition?

What Hayk
  • 23
  • 2

2 Answers2

0

Definitions is an array. If you want only the first result, you can use:

result.definitions[0].definition
Chris Foster
  • 2,639
  • 2
  • 23
  • 30
-1

What result.definitions is is an array.. So result.definitions[0] means the first value in the array, which is an object. Take the definition from this, and that'll work. result.definitions[0].definition

codeR developR
  • 468
  • 3
  • 13