Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- firstButton.onclick = () => createBubble();
- function createBubble(){
- let num = document.getElementById('number').value,
- bubble = [],
- randomBubble = [];
- while (0<num){
- bubble.push(num--);
- }
- for (let i = bubble.length - 1; i>=0 ;i-- ) {
- randomBubble.push(bubble.splice(Math.floor(Math.random() * (i + 1)), 1));
- }
- function loopOut(num) {
- setTimeout(function () {
- let inp = document.createElement("span");
- inp.innerHTML = randomBubble[num];
- let outJ = document.getElementById('out');
- outJ.parentNode.insertBefore(inp, outJ);
- num++;
- if(num<randomBubble.length) loopOut(num)
- }, 500)
- }
- loopOut(num);
- return randomBubble;
- }
- setTimeout(()=>alert(qwe), 5000);
- function sortBubble(){
- let a = createBubble();
- alert(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement