Consider a string made of only digits Replace each pair of a
Consider a string made of only digits. Replace each pair of adjacent digits by their sum. So if the input is \"128743128\" the output should be \"315738\".
JavaScript Help**
Solution
ANS;
<html>
 <body>
 <script>
 var txt=prompt(\"Enter a string(Only Digits)\");//to read input string
 //var txt=\"128743128\";
 var i=txt.length;//finding length of a string
 var count;
 var output=\"\";//output string
 if(i%2 == 0)//even number of digits
 {
    for(var j=1;j<txt.length;j=j+2)
    {
        count=txt.codePointAt(j)-48 + txt.codePointAt(j-1)-48;
        output=output+count;//appending count to output string
    }
 }
 else//odd number of digits
 {
    for(var j=1;j<txt.length;j=j+2)
    {
        count=txt.codePointAt(j)-48 + txt.codePointAt(j-1)-48;
        output=output+count;
    }
    output=output+(txt.codePointAt(txt.length-1)-48);//appending remaining single digit
 }
 document.writeln(\"<h1>Output: \"+output);
 </script>
 </body>
 </html>

