Skip to content

Commit 33b6117

Browse files
authored
Create 3754-concatenate-non-zero-digits-and-multiply-by-sum-i.js
1 parent 9196d12 commit 33b6117

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
var sumAndMultiply = function(n) {
6+
const s = '' + n
7+
let x = '', sum = 0
8+
for(const e of s) {
9+
if(e === '0') continue
10+
else {
11+
x += e
12+
sum += +e
13+
}
14+
}
15+
x = +x
16+
17+
return x * sum
18+
};

0 commit comments

Comments
 (0)