Coding Challenge: Vue.js App Structure

Test your skills by solving the coding challenge presented below.

Problem

Define a function getNumWords(sentence) that takes a sentence (string) as an argument and returns the number of words in the sentence.

Integrate the function in the below-provided Vue.js application code skeleton and show the output at line 10 as prompted.

Sample Input:

getNumWords('I am a sentence')

Sample Output:

4

As seen, there are four words in the following sentence: ‘I am a sentence.’

Get hands-on with 1200+ tech skills courses.