Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- var start = parseInt(input[0]);
- var end = parseInt(input[1]);
- var notBeer = "<li><span class='num'>NUMBER</span></li>\n";
- var beer = "<li><span class='rakiya'>NUMBER</span><a href=\"view.php?id=NUMBER>View</a></li>\n";
- var output = '<ul>\n';
- var isBeer = false;
- for(var a = start; a <= end; a++) {
- var number = String(a);
- var num = number;
- for(var b = 0; b < number.length; b++) {
- var digits = number[b] + number[b+1];
- if(num.split(digits).length - 1 > 1 ) {
- // console.log("There is a beer - " + digits );
- isBeer = true;
- }
- }
- if(isBeer) {
- isBeer = false;
- var addNumber = beer.replace(/NUMBER/g,number);
- output +=addNumber;
- } else {
- var addNumber = notBeer.replace("NUMBER",number);
- output += addNumber;
- }
- }
- output += "</ul>";
- console.log(output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement