123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- //html tree
- let body = {
- tagName: "body",
- subTags: [
- {
- tagName: "div",
- subTags: [
- { tagName: 'span', text: 'Enter a data please:' },
- { tagName: 'br' },
- { tagName: 'input', attr: { type: 'text', id: 'name' } },
- { tagName: 'input', attr: { type: 'text', id: 'surname' } },
-
- ]
- },
- {
- tagName: 'div',
- subTags: [
- { tagName: 'button', text: 'ok', attr: { id:'ok' } },
- { tagName: 'button', text: 'Cancel', attr: { id: 'cancel' } }
- ]
- }
-
- ]
-
- }
- body.subTags[1].subTags[1].text
- body.subTags[0].subTags[3].attr.id
- //declarative fields
- var notebook = {
- brand: prompt('Enter brand'),
- type: prompt('Enter type'),
- model: prompt('Enter model'),
- ram: prompt('Enter ram'),
- size: prompt('Enter size'),
- weight: prompt('Enter weight'),
- resolution: {
- width: prompt('Enter width'),
- height: prompt('Enter height'),
- },
- };
- var phone = {
- brand: prompt('What is brand?'),
- model: prompt('What is model?'),
- ram: +prompt('Enter you ram?'),
- color: prompt('What is color?'),
-
- };
- //object links
- var person = {
- name: prompt('What is you name?'),
- surname: prompt("What is you surname?"),
- married: confirm('Are you married?'),
-
- }
- person.phone = phone
- person.notebook = notebook
- phone.owner = person
- notebook.owner = person
- //imperative array fill 3
- let th = []
- th[1] = prompt();
- th[2] = prompt();
- th[0] = prompt()
- //while confirm
- let qw = "";
- while (qw !== true) {
- qw = confirm('?')
- }
- //array fill
- let mass = [];
- let qu = ""
- while ( (qu = prompt('Чего д0бавить?')) !== null) {
-
- mass.push(qu)
- }
- //array fill nopush
- let mass1 = [], i=0 ;
- let qu1 = ""
- while ( (qu1 = prompt('Чего д0бавить?')) != null) {
-
- mass1[i++] = qu1
-
- }
- //infinite probability
- let numb = 0
- while ( Math.random() < 0.9) {
- numb += 1
-
- }
- alert(numb)
- //empty loop
- let a = ''
- while (a != prompt());
- //progression sum
- let aa = 0
- for (i = 1; i < 100; i += 3){
- aa = aa + i
- }
- //chess one line
- let q = ""
- for (i = 0; i < 15; i++){
- if (i % 2 === 1) {
- q = q + " "
- } else {
- q = q + "#"
- }
-
- }
- //numbers
- /*let w = ""
- for (let i = 0; i < 10; i++){
- w = w + "0123456789\n"
-
- }
- console.log(w) */
- str = ""
- for (let i = 0; i < 10; i++){
- str = str + '\n'
- for (let j = 0; j < 10; j++){
- str = str + j
- }
- }
- console.log(str)
- //chess
- let chess = ""
- for (let i = 0; i < 6; i++) {
-
- chess += '\n'
-
- for (let j = 0; j < 6; j++) {
- if (i % 2 === 1) {
- chess += ".#"
- } else {
- chess += "#."
- }
-
-
- }
- }
- alert(chess)
- // cubes
- let mass11 = []
- for (let i = 0; i < 15; i++){
- mass11.push(i ** 3)
-
- }
- console.log(mass11[i])
- //multiply table
- let mas = []
- for (let i = 0; i < 10; i++){
- mas[i] = []
- for (let j = 0; j < 10; j++){
- mas[i][j] = [j*i] ; //<============ или ============> mas[i].push(i*j)
- }
- }
- //matrix to html table тут страшные и непонятные вещи происходили , короче , как-то склепал
- document.write( "<table border='1'>")
- let mas = []
- for (let i = 1; i < 10; i++){
- mas[i] = []
- document.write("<tr>")
- for (let j = 1; j < 10; j++){
-
- document.write( `<td>${mas[i][j] = [j * i]}</td> `)
-
- }
- document.write("</tr>")
- }
- document.write("</table>")
- //Задание на синий пояс: Треугольник
- let n = 6;
- for (let i = 1; i <= n; i++) {
- let str = '';
- for (j = 1; j <= 2 * n - 1; j++) {
- if (j >= n - (i - 1) && j <= n + (i - 1)) {
- str += '#';
- } else {
- str += '.';
- }
- }
- console.log(str);
- }
|