Skip to content

Commit eea2633

Browse files
author
Kyle Maune
committed
added solution for number search
1 parent 8379aba commit eea2633

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Medium Difficulty/numberSearch.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// coderbyte solution for number search
2+
// splashinn
3+
4+
function numberSearch(str) {
5+
var sum=0;
6+
var lets=0;
7+
for(var i=0;i<str.length;i++) {
8+
var c = str.charCodeAt(i);
9+
if((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
10+
lets++;
11+
if(c>=48 && c<=57)
12+
sum += c - 48;
13+
}
14+
return Math.round(sum/lets);
15+
}

0 commit comments

Comments
 (0)