-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (29 loc) · 1.14 KB
/
script.js
File metadata and controls
36 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let phraseInput = document.querySelector('#phrase');
let iterations = document.querySelector('#number');
let initIterations = document.querySelector('#init');
let btn = document.querySelector('#enviar');
phraseInput.addEventListener('change', function(e){
phraseInput.value = phraseInput.value.replaceAll('`', '');
phraseInput.value = '`'+phraseInput.value+'`';
})
btn.addEventListener('click', function(){
let phrase = phraseInput.value;
phrase = phrase.replaceAll('x', '${b}');
let inicio = initIterations.value;
let iteraciones = iterations.value;
console.log(phrase);
console.log(inicio);
console.log(iteraciones);
let code = "";
for(var b = parseInt(inicio); b < (parseInt(iterations.value)+1); b++){
console.log(`Entramos al bucle ${b} el elemento a dibujar es ${phrase}`);
code += eval(phrase)+'\n';
}
document.querySelector("#resultado").value = code;
})
// Copiar y pegar
document.querySelector("#copy").addEventListener('click',function(){
var content = document.querySelector("#resultado");
content.select();
document.execCommand('copy');
})