|
@@ -153,6 +153,8 @@
|
|
|
document.write(str);*/
|
|
|
|
|
|
//----------Blue belt
|
|
|
+
|
|
|
+ //появляется ячейка table -> {tbody}? -> tr -> td
|
|
|
var someTree = {
|
|
|
tagName: "table",
|
|
|
subTags: [
|
|
@@ -175,27 +177,107 @@
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- container.innerHTML=createHTML(someTree);
|
|
|
-
|
|
|
- function createHTML(obj){
|
|
|
-
|
|
|
- for(let i in obj){
|
|
|
- let tag=document.createElement(obj.tagName);
|
|
|
- if(i==subTags){
|
|
|
- for(let item of subTags){
|
|
|
- let tag2=document.createElement(item[0].tagName);
|
|
|
- tag.append()
|
|
|
-
|
|
|
- if(item[0].subTags){
|
|
|
-
|
|
|
- }
|
|
|
+ let str='';
|
|
|
+ for(let item in someTree){
|
|
|
+ if(item=='tagName'){
|
|
|
+ let [key] = Object.keys(someTree['attrs']);
|
|
|
+ let [value]= Object.values(someTree['attrs']);
|
|
|
+ str+=`<${someTree['tagName']} ${key}=${value}>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(item=='subTags'){
|
|
|
+ for(let item2 of someTree[item]){
|
|
|
+ for(let item3 in item2){
|
|
|
+ // str+=`<${item2['tagName']}>`;
|
|
|
+ if(item3=='subTags'){
|
|
|
+ for(let item4 of item2['subTags']){
|
|
|
+ console.log(item4);
|
|
|
+ for(let item5 in item4){
|
|
|
+ if(item5=='tagName'){
|
|
|
+ str+=`<${item4['tagName']}>${item4['text']}</${item4['tagName']}>`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- tag.append()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ document.write(str);
|
|
|
+
|
|
|
+//------destruct array
|
|
|
+ //четные числав переменные even1, even2
|
|
|
+ /*let arr=[1,2,3,4,5,'a','b','c'];
|
|
|
+ for(let i=0; i<arr.length; i++) {
|
|
|
+ for(let j=0; j<arr.length; j++ ){
|
|
|
+ if(arr[j]%2 === 1){
|
|
|
+ arr.splice(j,1)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ let [even1,even2]=arr;
|
|
|
+ console.log(arr);
|
|
|
+ console.log(even1+" : "+even2); */
|
|
|
+
|
|
|
+ //нечетные в odd1, odd2, odd3
|
|
|
+ /*let arr2=[1,2,3,4,5,'a','b','c'];
|
|
|
+ let [odd1,odd2,odd3]=arr2.filter(x=>x%2);
|
|
|
+ console.log(odd1+" : "+odd2+' : '+odd3);*/
|
|
|
+
|
|
|
+ //буквы в отдельный массив
|
|
|
+ /*let arr3=arr2.filter(function(x){
|
|
|
+ if(!Number(x)){
|
|
|
+ return x;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(arr3);*/
|
|
|
+
|
|
|
+//------destruct string
|
|
|
+ //число в переменную number
|
|
|
+ /*let arr=[1,'abc'];
|
|
|
+ let [number]=arr;
|
|
|
+ console.log(number);*/
|
|
|
+
|
|
|
+ //букву а в переменную s1
|
|
|
+ //букву b в переменную s2
|
|
|
+ //букву с в переменную s3
|
|
|
+ /*let [s1,s2,s3]=[...arr[1]];
|
|
|
+ console.log(s1+" : "+s2+" : "+s3);*/
|
|
|
+
|
|
|
+//------destruct 2
|
|
|
+ /*let obj = {
|
|
|
+ name: 'Ivan',
|
|
|
+ surname: 'Petrov',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ name: 'Maria'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'Nikolay'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+
|
|
|
+ let {children:[{name:name1},{name:name2}]}=obj;
|
|
|
+ console.log(name1 + " : "+name2);*/
|
|
|
+
|
|
|
+//------destruct 3
|
|
|
+ let arr = [1,2,3,4,5,6,7,10];
|
|
|
+ let [a,b]=arr;
|
|
|
+
|
|
|
+ console.log(a+' : '+b+' : '+length);
|
|
|
+
|
|
|
+ //вопрос:как дуструктуризовать length
|
|
|
+
|
|
|
+//------Black belt
|
|
|
+ //in process
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|