Write a recursive function that takes an array of words and return the array with a the words capitalized
Answers
Answered by
12
Answer:
function
5 array of words
Answered by
0
A recursive function that takes an array of words and returns the array with 'a' the words capitalized.
Explanation:
Recursive function: Recursion is the process by which an issue is defined in (a more basic version of) itself (or a solution to a problem).
We will use C language progam to define a recursive function.
function capitalize(arr=[]){
const makeCapital = (str)=>{
return str[0].toUpperCase() + str.slice(1).toLowerCase()
}
if(arr.length > 0){
return [makeCapital(arr.shift())].concat(capitalize(arr))
}
return arr
}
Similar questions