Leonardo Sotelo

All generations.

generate functionWed, 14 Jun 2023

funtion that generate a red div that rotate constantly and has position absolute using this syntax function cubologo(top, left, parent) { } so I can set the top and left position and its parent where it will be append with the return the element

function cubologo(top, left, parent) { var logo = document.createElement("div"); logo.classList.add("logo"); logo.style.top = top + "px"; logo.style.left = left + "px"; parent.appendChild(logo); return logo; }

Javascript
View
generate functionMon, 26 Jun 2023

funtion that generate a typing text using this syntax function typeText(words, bgcolor, textcolor, speed) { let note = document.createElement('div') document.body.appendChild(note) }

function typeText(words, bgcolor, textcolor, speed) { let note = document.createElement('div') document.body.appendChild(note) note.style.background = bgcolor note.style.color = textcolor note.style.fontSize = '1.2rem' note.style.margin = '1rem 0' note.style.padding = '.5rem' const letter = words.split('') letter.forEach((letter, i) => { setTimeout(() => note.textContent += letter, 70 * i) }) if (speed) { setTimeout(() => note.remove(), 70 * letter.length + speed) } else { setTimeout(() => note.remove(), 70 * letter.length + 350) } } typeText('This is a message.', 'lightblue', 'white', 600)

Javascript
View
generate functionMon, 24 Apr 2023

funtion to play a random sound from an array

function playSound() { var sounds = [ new Audio('assets/melos/melo1.mp3'), new Audio('assets/melos/melo2.mp3'), new Audio('assets/melos/melo3.mp3'), new Audio('assets/melos/melo4.mp3'), new Audio('assets/melos/melo5.mp3'), new Audio('assets/melos/melo6.mp3'), ]; sounds[Math.floor(Math.random() * sounds.length)].play(); }

Javascript
View
generate functionTue, 30 May 2023

funtion that generate random words with random length using only letters

import random #this function takes a random word from a list and capitalize it def random_words(words): return random.choice(words).capitalize() #this function makes a random lenght def length(words): return len(random_words(words)) #this function counts how many times the letter 'a' apears in the random word def count_a(words): sum = 0 for i in random_words(words): if i == 'a': sum = sum + 1 return sum #this function makes a list of random words with random lenght def random_list(words): list = [] for i in range(10): list.append(random_words(words)) return list #this function counts how many times the letter 'a' apears in the random word def count_a(words): sum = 0 for i in random_words(words): if i == 'a': sum = sum + 1 return sum #this

Javascript
View
generate functionWed, 14 Jun 2023

funtion that generate a red div that rotate alternate and has position absolute using this syntax function cubologo(top, left, parent) { } so I can set the top and left position and its parent where it will be append

function cubologo(top, left, parent) { var div = document.createElement('div'); div.style.backgroundColor = 'red'; div.style.width = '100px'; div.style.height = '100px'; div.style.position = 'absolute'; div.style.top = top; div.style.left = left; div.style.transform = 'rotateY(90deg)'; div.style.transition = 'transform .5s' document.querySelector(parent).appendChild(div); } cubologo('300px', '300px', 'body');

Javascript
View

Want to kickstart your project?Use the new AI Studio to create your code