Code the following function in JAVASCRIPT (Use of the given list of inbuilt functions is not allowed)
Write a function that searches the string (passed as first argument) for the character (passed as second argument) and changes the case for all instances of that char found in string. The function should return the new string as shown in example below: function(‘abRA’, ‘a’) // returns ‘AbRa’
<script>
function search(string,character) {
var result="";
for(var i=0;i<string.length;i=i+1){
if(string[i]==character){
var asc_val=string[i].charCodeAt(0);
if(asc_val>=65 && asc_val<=90){
result=result+String.fromCharCode(asc_val+32);
}
else{
result=result+String.fromCharCode(asc_val-32);
}
}
else{
result=result+string[i]
}
}
return result
}
document.write(search('aaaBAchea','a')+"<br>");
document.write(search('aaaBAchea','A')+"<br>");
document.write(search('abRA','a')+"<br>");
</script>
Please give a like
Code the following function in JAVASCRIPT (Use of the given list of inbuilt functions is not...
CODE THE FOLLOWING FUNCTIONS IN JAVASCRIPT (USE OF THE ABOVE MENTIONED IN BUILT FUNCTIONS IS NOT ALLOWED) Write a function that accepts an array as argument. The function should loop through the array elements and accumulate the sum of ASCII value of each character in element and return the total. For example: function([‘A’, ‘bc’, 12]); // returns 361 which is the sum of 65 + 98 + 99 + 49 + 50 Write a function that accepts two arguments (a...
Note: Please test your output on the console and also avoid the functions below. We were unable to transcribe this image6. Write a function which combines two strings which are passed as 7. The trimLeft) method removes whitespace from the left end of a 8. Write a function which removes whitespace from both ends of the parameters. Mix one character from each string and return the concatenated result. function('ABC','Defg) return ADBeCfg string. Whitespace in this context is all the whitespace...