Duplicate commands | Sololearn: Learn to code for FREE!


Duplicate commands

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


7/10/2021 9:00:52 PM


2 Answers

New Answer


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'));


visph Thanks