0

Duplicate commands

How to remove duplicate commands without equalizing variables, if it's possible https://code.sololearn.com/Wuxqz69rNhcy/?ref=app

10th Jul 2021, 9:00 PM
nikita
2 Respostas
+ 3
you can do: let b = a.cloneNode(); let c = a.cloneNode(); or you can initialize a list of element: let [a, b, c] = [...Array(3)].map(() => document.createElement('input')); you could also create a new function to shorter the writing: let create = document.createElement.bind(document); let [a, b, c] = [...Array(3)].map(() => create('input'));
10th Jul 2021, 9:33 PM
visph
visph - avatar
+ 1
visph Thanks
10th Jul 2021, 9:43 PM
nikita