Duplicate commands | Sololearn: Learn to code for FREE!

0

Duplicate commands

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

js

7/10/2021 9:00:52 PM

nikita

2 Answers

New Answer

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

+1

visph Thanks