|
@@ -9,18 +9,15 @@
|
|
<script>
|
|
<script>
|
|
|
|
|
|
//---------sort
|
|
//---------sort
|
|
- let persons=[
|
|
|
|
|
|
+ /*let persons=[
|
|
{name:'Ivan',age:17},
|
|
{name:'Ivan',age:17},
|
|
{name:'Maria',age:35},
|
|
{name:'Maria',age:35},
|
|
{name:'Aleksei',age:73},
|
|
{name:'Aleksei',age:73},
|
|
{name:'Iykov',age:12}
|
|
{name:'Iykov',age:12}
|
|
];
|
|
];
|
|
|
|
|
|
- function so(arr,field,bool=true){
|
|
|
|
|
|
+ function sort(arr,field,bool=true){
|
|
if(bool==false){
|
|
if(bool==false){
|
|
- for(let i of arr){
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
arr.sort((a,b)=>a[field]>b[field]?-1:1);
|
|
arr.sort((a,b)=>a[field]>b[field]?-1:1);
|
|
}
|
|
}
|
|
if(bool==true){
|
|
if(bool==true){
|
|
@@ -28,12 +25,8 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /*function so(arr,field,bool=true){
|
|
|
|
- in process
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
- so(persons,'age',false);
|
|
|
|
- console.log(persons);
|
|
|
|
|
|
+ sort(persons,'age');
|
|
|
|
+ console.log(persons);*/
|
|
/*so(persons,'name',false);
|
|
/*so(persons,'name',false);
|
|
console.log(persons);*/
|
|
console.log(persons);*/
|
|
|
|
|
|
@@ -93,15 +86,27 @@
|
|
};
|
|
};
|
|
|
|
|
|
function filter(obj,cb){
|
|
function filter(obj,cb){
|
|
- //in process
|
|
|
|
|
|
+ return Object.entries(obj).filter(e => cb(...e)).reduce((a,[b, c] = b) => (a[b] = c, a),{});
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
console.log(filter(phone,(key,value)=>key=='color'|| value==2));*/
|
|
console.log(filter(phone,(key,value)=>key=='color'|| value==2));*/
|
|
|
|
|
|
//---------object map
|
|
//---------object map
|
|
- //in process
|
|
|
|
|
|
+ /*function map(obj,cb){
|
|
|
|
+ let obj2 = {};
|
|
|
|
+ for(var key in obj){
|
|
|
|
+ Object.assign(obj2,cb(key, obj[key]));
|
|
|
|
+ }
|
|
|
|
+ return obj2;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ console.log(map({name:"Ivan",age:17},function(key,value){
|
|
|
|
+ let result={};
|
|
|
|
+ result[key+'_']=value+'$';
|
|
|
|
+ return result;
|
|
|
|
+ }));*/
|
|
|
|
|
|
//---------sum (done)
|
|
//---------sum (done)
|
|
/*function sum(n){
|
|
/*function sum(n){
|
|
@@ -116,7 +121,7 @@
|
|
|
|
|
|
|
|
|
|
//----------HTML Tree (blue belt - recursive) (done)
|
|
//----------HTML Tree (blue belt - recursive) (done)
|
|
- var someTree = {
|
|
|
|
|
|
+ /*var someTree = {
|
|
tagName: "table",
|
|
tagName: "table",
|
|
subTags: [
|
|
subTags: [
|
|
{
|
|
{
|
|
@@ -164,7 +169,7 @@
|
|
|
|
|
|
createTree(someTree);
|
|
createTree(someTree);
|
|
console.log(str);
|
|
console.log(str);
|
|
- document.write(str);
|
|
|
|
|
|
+ document.write(str);*/
|
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|