Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to solve this using JavaScript? How poetical a word is can be found by looking at three factors: - Presence of vowels, A, E,
How to solve this using JavaScript?
How poetical a word is can be found by looking at three factors: - Presence of vowels, A, E, I, O,U, and Y, because these are soft and pleasing - Absence of the letters K and X, because these are harsh and unpleasant - Order in the poem, because earlier words are more important A poem is a series of English words separated by spaces. We can assign a poetry score to any word in a poem by following these steps: - Count the number of vowels - Subtract 1 for each ' k ' - Subtract 2 for each ' X ' If multiple words in a poem have the same score, the earlier word is more poetical. Example poem = "Like feeble age he reeleth from the day" The poetry scores of these words are 1,3,2,1,3,1,1,1 and "feeble" is the most poetical word. Function Description Complete the function mostPoeticalWord in the editor below. mostPoeticalWord has the following parameter(s): string poem: a poem string Returns: string: the word that is first occurrence with the highest poetry score Constraints - 1 length of poem 105 - The poem string consists of spaces and letters in the range ascii[a-z, A-Z, ] onlyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started