Question: Write a JavaScript function on the following: a.) Create a function to count the occurrence of a substring in a string. Function will accept 2

Write a JavaScript function on the following: a.) Create a function to count the occurrence of a substring in a string. Function will accept 2 parameters; first parameter is the string to be searched on and the second will the string to be search. Function should also validate the parameter values, the second argument is not allowed to have empty strings but can also accept integers. a b.) Create a function that will truncate a string/phrase to a certain number of words. Function should validate if input string is a valid sentence or phrase
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
