Skip to content

Instantly share code, notes, and snippets.

@phwb
Last active August 7, 2018 15:36
Show Gist options
  • Save phwb/6c842a49f1424b0d02ff0584eda55e3b to your computer and use it in GitHub Desktop.
Save phwb/6c842a49f1424b0d02ff0584eda55e3b to your computer and use it in GitHub Desktop.
// объявляем константы
const MAX_VALUE = 10;
// объявляем фукнции
function getData () {
let result = [];
for (let i = 0; i < MAX_VALUE; i += 1) {
result = result.concat(i);
}
return result;
}
function createItems (data) {
const fragment = document.createDocumentFragment();
for (var i = 0, len = data.length; i < len; i += 1) {
const item = document.createElement('li');
item.textContent = i;
fragment.appendChild(item);
}
return fragment;
}
// работа с данными
const data = getData();
const items = createItems(data);
// работа с DOM
const ul = document.createElement('ul');
ul.appendChild(items);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment