Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lookandsay(x) {
- var ans = "";
- var current = x[0], count = 1;
- for (var i = 1; i < x.length; i++)
- if (x[i] == current)
- count++;
- else
- ans += count.toString() + current, count = 1, current = x[i];
- ans += count.toString() + current;
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement