In XYZ country there is rule that car’s engine no. depends upon car’ number plate. Engine no is sum of all the integers present on car’s Number plate.The issuing authority has hired you in order to provide engine no. to the cars.Your task is to develop an algorithm which takes input as in form of string(Number plate) and gives back Engine number.
In XYZ country there is rule that car’s
engine no. depends upon car’ number plate. Engine no is sum of all the
integers present on car’s Number plate.The issuing authority has hired
you in order to provide engine no. to the cars.Your task is to develop
an algorithm which takes input as in form of string(Number plate) and
gives back
Engine number.
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 = (data);
var b=data.join('');
var c=b.split("").map(val=>Number(val))
var sum=0;
for(i=0;i<c.length;i++)
{d=c[i]
if(isNaN (d))
sum =sum;
else
sum= sum+d
}
console.log(sum)
});
Engine number.
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 = (data);
var b=data.join('');
var c=b.split("").map(val=>Number(val))
var sum=0;
for(i=0;i<c.length;i++)
{d=c[i]
if(isNaN (d))
sum =sum;
else
sum= sum+d
}
console.log(sum)
});
Comments
Post a Comment