Question

Write a function that converts letters in string that is passed to, to lowercase: function("ALPHABET"); //...

Write a function that converts letters in string that is passed to, to lowercase: function("ALPHABET"); // returns "alphabet"

no built in javascript methods, must output to the console

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function lower(string) {
var answer = ''

for (var i = 0; i < string.length; i++) {
var ascii = string.charCodeAt(i)
if (ascii >= 65 && ascii <= 90) {
answer += String.fromCharCode(ascii + 32)
} else {
answer += string.charAt(i)
}
}
return answer
}

============================================
SEE OUTPUT

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Write a function that converts letters in string that is passed to, to lowercase: function("ALPHABET"); //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a function that converts all the lowercase letters in an array of 10 characters to...

    Write a function that converts all the lowercase letters in an array of 10 characters to uppercase. This should be done by directly manipulating the ASCII values of the characters. The user should be prompted to enter the characters.

  • Define a function num_letters(...) that evaluates a string consisting of numbers, letters, and symbols that returns...

    Define a function num_letters(...) that evaluates a string consisting of numbers, letters, and symbols that returns the total number of letters of the alphabet (upper and lowercase) in the string. If there are no letters in the function, then it should return the message "no way". As an example, the following code fragment: st1="aihj{234][o" print (num_letters(st1)) should produce the output: 5

  • Create the function front33 that accepts a string as an argument. The first three letters of...

    Create the function front33 that accepts a string as an argument. The first three letters of the string are added to the front of the string and at the end of the string. If the string length is less than 3, use whatever chars are present. The function takes a string character and returns a new string taking the first three characters of the input string and adding them to the front and the back of the string. (must be...

  • JavaScript 1. Write a function which receives one argument (string) and converts the string to uppercase....

    JavaScript 1. Write a function which receives one argument (string) and converts the string to uppercase. function('abc') // returns 'ABC' 2. Write a function that accepts an array and a value. Find and return the first array element with bigger than given value. function([5,15,4],6) //returns 15 DO NOT USE THESE IN-BUILT FUNCTIONS BELOW endsWith() includes() indexOf() lastIndexOf() localeCompare() match() repeat() replace() search() slice() split() startsWith() substr() substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase() toString() toUpperCase() trim() valueOf() trimLeft and trimRight unshift() valueOf() includes()...

  • Write a javascript function that accepts 3 arrays and returns a string of the elements sorted...

    Write a javascript function that accepts 3 arrays and returns a string of the elements sorted in ascending value, with duplicates removed. Return all alphabetic characters in lowercase. E.G. function([ 1,2,3, d], [5, 3, 0, ‘a’], [‘a’,’d’,9]) returns “0,1,2,3,5,9,a,d” E.G. function(['w', 'i', 'H', 5], [8, 5, 9, 'c', 'Z'], [6, 4, 'a', 'b', 'y']) returns “4,5,6,8,9,a,b,c,h,i,w,y,z” we must not use ' sort, remove, split,join and any built-in fucntions

  • animali 32. How many strings of six lowercase letters from the En- glish alphabet contain IS...

    animali 32. How many strings of six lowercase letters from the En- glish alphabet contain IS a) the letter a? b) the letters a and b? Osadno-o lls i d c) the letters a and b in consecutive positions with a preceding b, with all the letters distinct?) d) the letters a and b, where a is somewhere to the left of b in the string, with all the letters distinct? into

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • using basic c++ and use no functions from c string library b) Write a fragment of...

    using basic c++ and use no functions from c string library b) Write a fragment of code (with declarations) that reads a pair of words from the keyboard and determines how many letters in corresponding positions of each word are the same. The words consist only of the letters of the English alphabet (uppercase and lowercase). For example, if the words are coat and CATTLE, the following output should be generated: 012245 0122 matching letter in position 0 t is...

  • Define a function that counts the number of lowercase and uppercase letters in an input C-String....

    Define a function that counts the number of lowercase and uppercase letters in an input C-String. DO NOT DEFINE TWO SEPARATE FUNCTIONS. (in C++)

  • Write a function, value of (Word), which returns the value of a word of lowercase letters,...

    Write a function, value of (Word), which returns the value of a word of lowercase letters, where the value of the word is the sum of the number of each letter in Word. Use number of (Letter) as a helper function. Sample runs: >>> valueOf ('abe') 8 >>> valueOf ('dial') 26 >>>

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT