Given a string 'S' print the sum of weight of the String. A weight of character is defined as the ASCII value of corresponding character.
Given a string 'S' print the sum of weight of the String. A weight of
character is defined as the ASCII value of corresponding character.
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = String(data[0]);
var sum=0;
for (i=0;i<a.length;i++)
sum=sum+a.charCodeAt(i)
console.log(sum)
});
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = String(data[0]);
var sum=0;
for (i=0;i<a.length;i++)
sum=sum+a.charCodeAt(i)
console.log(sum)
});
Comments
Post a Comment