diff --git a/09/app.js b/09/app.js new file mode 100644 index 0000000..082c323 --- /dev/null +++ b/09/app.js @@ -0,0 +1,33 @@ +var mojePole = ["Intel", "AMD", "Asus", "NVidia","Samsung", "Nokia","Xiaomi", "ZTE"] +mojePole.sort(); +console.log(mojePole) + +//vypsání všech elementů +//document.getElementById("demo").innerHTML = mojePole + "
"; +//vypsání jednoho elementu +//document.getElementById("demo").innerHTML += mojePole[0]; + + +document.getElementById("demo").innerHTML = "Mám "+ mojePole.length + " Oblíbneých IT firem
"; + +// for metoda vypisování jednotlivých věcí z Pole +// for (let i = 0; i < mojePole.length; i++) { +// const element = mojePole[i]; +// var arrayText = "Mezi moje oblíbené IT firmy patří:"+ element+"
"; +// document.getElementById("demo").innerHTML += arrayText; +// } + +document.getElementById("demo").innerHTML += mojePole.join(" & "); + +mojePole.pop() +console.log(mojePole); + +mojePole.push("GIGABYTE"); +console.log(mojePole); + +mojePole.shift(); +console.log(mojePole); + +mojePole[3] = "ERROR"; +console.log(mojePole); + diff --git a/09/index.html b/09/index.html new file mode 100644 index 0000000..406840b --- /dev/null +++ b/09/index.html @@ -0,0 +1,25 @@ + + + + + + + Document + + +

JS Array

+ + +

+
+ +
+ + + + + + + + \ No newline at end of file diff --git a/09/todo.js b/09/todo.js new file mode 100644 index 0000000..03c0f74 --- /dev/null +++ b/09/todo.js @@ -0,0 +1,47 @@ +let todoarray = []; + +//načtení hodnot z paměti +let localTodo = localStorage.getItem("todoLocal"); +let flocalTodo = JSON.parse(localTodo); +//vygenerovaní uloženého textu z paměti +for (let i = 0; i < flocalTodo.length; i++) { + const element = flocalTodo[i]; + todoarray.push(element); +} +todoarray.forEach(createList); +//kontrola +console.log(todoarray); +//přidání textu +function addItem() { + let text = document.getElementById("todoitem").value; + + //přidání do pole + todoarray.push(text); + + //uložení do paměti počítače + let jsonPole = JSON.stringify(todoarray); + localStorage.setItem("todoLocal",jsonPole); + + console.log(todoarray); + + //vygenerovani list + //document.getElementById("todolist").innerHTML += "
  • " + todoarray + "
  • "; + document.getElementById("todolist").innerHTML = ""; + todoarray.forEach(createList); + +} +//*ForEach* funkce pro generovani listu +function createList(value, index){ +var deleteitem = ""; +document.getElementById("todolist").innerHTML += "
  • " + value + deleteitem + "
  • " +} +//odstranění listu +function removeItem(index) { + //odstranění 1 itemu z pole + todoarray.splice(index,1) + //znova generovaní listu + document.getElementById("todolist").innerHTML = ""; + todoarray.forEach(createList); + let jsonPole = JSON.stringify(todoarray); + localStorage.setItem("todoLocal",jsonPole); +} \ No newline at end of file