Question

Given a string . Find the numberical sum of the string . Example 1: Given String...

Given a string . Find the numberical sum of the

string .

Example 1:

Given String = "abcd"

Numerical

Sum = 1 + 2 + 3 + 4 = 10, Since a = 1 , b = 2 , c =3 and d = 4

it done html and javascript and plz do it in simple way

Homework Answers

Answer #1

I am not sure if you want me to write the code for html and javascript both for dom manipulation or just the code for function of getting the sum in Javascript.

I will write the Javascript code for the function called getStringSum() and if there's any further issue then ping me on it.

function getStringSum(str) {
    str = str.toLowerCase();
    let sum = 0;
    
    for(var i = 0; i < str.length; i++) {
        sum += str.charCodeAt(i) - 96;    
    }
    
    return sum
}

I hope this is upto your expectation and if it is kindly give an upvote.

Know the answer?
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
Similar Questions
Write a java script function that accepts a string as input and prints the 3rd, 5thand...
Write a java script function that accepts a string as input and prints the 3rd, 5thand 7thwordof input string with ‘-‘ in between the words. Spaces at the start and end of string must be ignored. it done html and javascript and plz do it in simple way
a) sum = 0 for letter in '12345' : sum = sum + int(letter) print('sum =...
a) sum = 0 for letter in '12345' : sum = sum + int(letter) print('sum = ', sum) Write a program which reads a string containing any characters from the user and prints the sum of the digits in the string. For example, if the string from the user is "I want 3 oranges and 24 bananas', then the output would be 9, since 3 + 2 + 4 = 9. Note that a character C is a digit if...
Hello I have a question about Java. example So when you put “sum 1 2 3”...
Hello I have a question about Java. example So when you put “sum 1 2 3” in console, you do not seperate those. Need a space between sum 1, 2 in the console. What is Sum? sum 1 2 3 6 (answer) sum 123456 21 sum 7 4 2 13 public static void main (String[] args) { System.out.Println(“What is Sum?”); String a=“”; a = scnr.nextLine(); String[] b = a.split(“”); if(b[0].equals(“sum”) { } I don’t know how to make code for...
HTML Assignment Question 7: Which of the following is NOT a correct description of JavaScript: A....
HTML Assignment Question 7: Which of the following is NOT a correct description of JavaScript: A. JavaScript is an interpreted/scripting language. B. JavaScript is a high-level programming language. C. JavaScript can be executed in web browser by JavaScript engine to make web pages more interactive, and user-friendly. D. JavaScript is a part of Java extension. Question 8: To provide JavaScript for an HTML document, you must add a <script> element in the <head> part of the document that either includes...
(In C) Given a list of numbers, find all the subsets of that list that sum...
(In C) Given a list of numbers, find all the subsets of that list that sum up to a given number? Ex: generate all subsets of {2, 4, 3, 1, 6, 5, 9} that sum up to 7. Output should be: {2, 4, 1}, {3, 4}, {5, 2}, {2, 1, 4}, {6, 1}
Given 2 4-sided dice (1,2,4,6) 1)Find the total numbers of outcomes 2)Find the sum of the...
Given 2 4-sided dice (1,2,4,6) 1)Find the total numbers of outcomes 2)Find the sum of the outcomes 3)Find the distribution of the Sum of the outcomes 4)Find the average of the sum of outcomes. Is this probability distribution? Why or why not? Is yes then graph using a histogram to prove it.
In C Programming Language: Given an integer N, find whether the sum of the digits calculated...
In C Programming Language: Given an integer N, find whether the sum of the digits calculated repeatedly till a single digit is obtained results in the sum of 1 or not. Display 1 if the sum of the digits of N can equal 1 else display 0. Example: For 199, Sum of digits = 1+9+9=19, 1+9=10, 1+0=1 so it should display 1 For 57, sum of digits = 5+7=12, 1+2=3 so it should display 0
C++ code Please: 1. Write a function to find the first occurrence of a given letter...
C++ code Please: 1. Write a function to find the first occurrence of a given letter in a string, return the index. If not found, return -1. (2’) Input example: str = "Hello World!" find(str, 'e') Input example: str = "a random string" find(str, '3') Output example: 1 Output example: -1
write a C program to find whether the given number of three digits is an integer...
write a C program to find whether the given number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is since 3**3 + 7**3 + 1**3 = 371. Output: Enter a number, or -999 to quit : 432 4**3 + 3**3 + 2**3 is not = 432 Enter a number, or -999 to quit : 371 3**3 + 7**3 + 1**3 is = 371...
JAVASCRIPT/HTML: Please read 10 numbers that are listed below, edit the code given to sort the...
JAVASCRIPT/HTML: Please read 10 numbers that are listed below, edit the code given to sort the numbers from least to greatest, and then print those numbers. 10 numbers = { 9, 3, 2, 1, 10, 30, 4, 6, 7, 8} Submit the code and a screenshot of the output. [Reference JavaScript code] <html> <body> <H1>prompt()</h1> <p id="pro"></p> <script> // Array creation var num= new Array(); var ix = 0; // Read 10 numbers for (ix = 0; ix < 10;...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT