Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions callback task/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

<script src="main.js"></script>
</body>
</html>
95 changes: 95 additions & 0 deletions callback task/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// ********************filter**************************//
function filtration(arr) {
let result = [];

for (let i = 0; i < arr.length; i++) {
if (arr[i] >= 0) {
result.push(arr[i]);
}
}
console.log(result)
}
filtration([1, 2, 3, 4, 5, 6,-7])


// ********************map**************************//
function mapping(arr){
let result2=[];
for(let i=0;i<arr.length;i++){
result2.push(arr[i]*10)
}
console.log(result2)
}

mapping([1, 2, 3, 4, 5, 6,-7])

// ********************some**************************//

let animalsId=[1,2,3,4,5,6]

let animalResult=animalsId.some(checkAnimalId);
console.log(animalResult)

function checkAnimalId(animal){
if(animal<7){
return true;
}
}

// second phase of some--------------//

function something(arr){
arr.forEach(element => {
if(element>=0){
console.log("true")
}else{
console.log(`${element} is false`)
}
});
}


// ********************every**************************//

let blocks=[1,2,3,4,5,6,66]

let blockResult=blocks.every(checkBlock);
console.log(blockResult)

function checkBlock(block){
if(block<=12){
return true;
}
}


// ********************reverse**************************//
let digits=[1,2,3,4,5,6];

function reversed(arr){
let temp=[];
for(let i=arr.length-1;i>=0;i--){
temp.push(arr[i]);
}
return temp;
}
let resultReversed=reversed(digits);
console.log(resultReversed);



// ********************concatination**************************//

function concatination(...rest){
let temp=[];
let num=[];
temp=rest.join();
for(let i=0;i<temp.length;i++){
if(temp[i] !==','){
num.push(+ temp[i]);
}
}
return num;
}
let resultConcatination=concatination([1,2,3,4,5,6],[1,2,3,4,5,6])
console.log(resultConcatination);