Question
Write a function named isAlpha that accepts a character (i.e., a string of length one) and returns true if it is a letter of the
Write a function named isAlpha that accepts a character (i.e., a string of length one) and returns true if it is a letter of the alphabet and false if it is not a letter of the alphabet. isAlpha should accept both uppercase and lowercase characters.
Write a function countLetters() that accepts a single string argument and uses isAlpha() to count the number of alphabetic letters in the string. You need to loop over each character in the string using a for loop, using the length property of string as part of the for loop conditional. You also need to use the string charAt() function to extract each character. You will call isAlpha() on each character in the string from within the loop. d. Write a function called countLettersWhile(), which must behave like countLetters, but it must use a while loop instead of a for loop to iterate over the string. e. Write another function countLettersDoWhile() that behaves like countLetters, but it must use a do ... while loop instead. f. Copy each function to the Chrome Console and test them.
Write the code in this type of formula -
function calculatedogyears(age)
{
let dogYears = 7 * age;
console.log("Your doggie is " + dogYears + " years old in dog years!");
return dogYears;
}
calculateDogAge(1);
Step 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