
Networks
bấm next qua 2 cái trên ảnh1. đáp án CALLBACK FUNCTIONS/** * Runs a callback function immediately * @param {function} callbackFunction */ function runCallback(callbackFunction) { callbackFunction(); } module.exports = runCallback; /** * Runs a callback function immediately * @param {function} callbackFunction */ function runCallback(callbackFunction) { setTimeout(callbackFunction, 1000); } module.exports = runCallback; class Dialog { onClose(callbackFunction) { this.carr = this.carr || []; th...

Sui Name Service ($SNS)
twitter :discord :Discord - Group Chat That's All Fun & GamesDiscord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.https://discord.comIt's finally here! Join our Crew3 and earn your spot in the $SNS DAO ➤ http://snsdomains.crew3.xyz ➤ New Quests added Daily! 10 people to Like/RT this tweet will also be selected for the Stork role - Winners selected below. #Sui isn't ready. Let&a...

tương tác Harpie
liên kết víxem ví mình dùng cái nào thì chọn - ví hold token thì chọn cái trên , ví chơi nft thì chọn cái dưới hoặc chọn cả 2 cũng đcchọn cái nào muốn bảo vệđợi cho nó load xong và import token mạng eth hoặc nft nào mà mình muốn bảo vệadd bn token hay nft tùy thích - sau đó chọn protecttốn chút fee ethnhư vậy là xong bước 1tiếp theo chọn setupnhập địa chỉ ví - tốn fee eth - nhập 1 địa chỉ ví khác ví đang dùngtiếp theo đến bước 3chọn mint FAU - tốn fee ethBẤM protect faucet token - tốn fee eth...
vui vẻ

Networks
bấm next qua 2 cái trên ảnh1. đáp án CALLBACK FUNCTIONS/** * Runs a callback function immediately * @param {function} callbackFunction */ function runCallback(callbackFunction) { callbackFunction(); } module.exports = runCallback; /** * Runs a callback function immediately * @param {function} callbackFunction */ function runCallback(callbackFunction) { setTimeout(callbackFunction, 1000); } module.exports = runCallback; class Dialog { onClose(callbackFunction) { this.carr = this.carr || []; th...

Sui Name Service ($SNS)
twitter :discord :Discord - Group Chat That's All Fun & GamesDiscord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.https://discord.comIt's finally here! Join our Crew3 and earn your spot in the $SNS DAO ➤ http://snsdomains.crew3.xyz ➤ New Quests added Daily! 10 people to Like/RT this tweet will also be selected for the Stork role - Winners selected below. #Sui isn't ready. Let&a...

tương tác Harpie
liên kết víxem ví mình dùng cái nào thì chọn - ví hold token thì chọn cái trên , ví chơi nft thì chọn cái dưới hoặc chọn cả 2 cũng đcchọn cái nào muốn bảo vệđợi cho nó load xong và import token mạng eth hoặc nft nào mà mình muốn bảo vệadd bn token hay nft tùy thích - sau đó chọn protecttốn chút fee ethnhư vậy là xong bước 1tiếp theo chọn setupnhập địa chỉ ví - tốn fee eth - nhập 1 địa chỉ ví khác ví đang dùngtiếp theo đến bước 3chọn mint FAU - tốn fee ethBẤM protect faucet token - tốn fee eth...
vui vẻ

Subscribe to meteosrds

Subscribe to meteosrds
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers




function sortUp(array) {
return array.sort(function comparison(a, b) {
if (b < a) {
return 1;
}
if (a < b) {
return -1;
}
return 0;
});
}
module.exports = sortUp;

function sortDown(array) {
return array.sort(function comparison(a, b) {
if (b < a) {
return -1;
}
if (a < b) {
return 1;
}
return 0;
});
}
module.exports = sortDown;

function sortStringsUp(array) {
return array.sort(function comparison(a, b) {
return a.localeCompare(b);
});
}
module.exports = sortStringsUp;

function sortStringsDown(array) {
return array.sort(function comparison(a, b) {
if (a.localeCompare(b) === 1) {
return -1;
}
if (a.localeCompare(b) === -1) {
return 1;
}
return a.localeCompare(b);
});
}
module.exports = sortStringsDown;

function sortStudents(students) {
return students.sort(function comparison(a, b) {
if (a.graduated !== b.graduated) {
if (a.graduated) {
return -1;
} else {
return 1;
}
}
if (a.grade > b.grade) {
return -1;
}
if (a.grade < b.grade) {
return 1;
}
return 0;
});
}
module.exports = sortStudents;

const MONTHS = [
'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
];
function sortByMonth(events) {
return events.sort(function comparison(a, b) {
let ai = MONTHS.indexOf(a.month);
let bi = MONTHS.indexOf(b.month);
if (ai < bi) {
return -1;
}
if (ai > bi) {
return 1;
}
return 0;
});
}
module.exports = sortByMonth;


function plusOne(arr) {
return arr.map(function (x) {
return (x + 1);
});
}
module.exports = plusOne;

function squareRoot(arr) {
return arr.map(function (x) {
return Math.sqrt(x);
});
}
module.exports = squareRoot;

/**
* Given a number n, square it.
*
* @param {number} n
* @return {number} n squared
*/
function squared(n) {
return (n * n);
}
module.exports = squared;

const squared = require('./squared');
function squaredMap(arr) {
return arr.map(squared);
}
module.exports = squaredMap;

function addScore(players) {
let i = 0;
return players.map(function (player) {
i++;
let one = player;
if (i < 4) {
one.score = one.score + 10;
}
return one;
});
}
module.exports = addScore;

function addScore(players) {
let i = 0;
return players.map(function (player) {
i++;
let one = player;
if (i < 4) {
one.score = one.score + 10;
}
return one;
});
}
module.exports = addScore;


function lessThanFive(array) {
return array.filter(function (e) {
return (e < 5);
});
}
module.exports = lessThanFive;

function onlyTrue(array) {
return array.filter(function (e) {
return e;
});
}
module.exports = onlyTrue;

function shortStrings(array) {
return array.filter(function (e) {
return (e.length <= 3);
});
}
module.exports = shortStrings;

function topStudents(array) {
return array.filter(function (e) {
return (e.grade >= 90);
});
}
module.exports = topStudents;

function firstThree(array) {
let i = 0;
return array.filter(function (e) {
i++;
if (i < 4) {
return true;
} else {
return false;
}
});
}
module.exports = firstThree;

function unique(array) {
let a = [];
return array.filter(function (e) {
if (a.indexOf(e) === -1) {
a.push(e);
return true;
}
return false;
});
}
module.exports = unique;


// numbers is an array full of numbers
// let's add all the numbers and return the sum
// i.e. [1,2,3,4,5] => 15
function sum(numbers) {
return numbers.reduce((accumulator, currentValue) => {
accumulator = accumulator + currentValue;
return accumulator;
});
}
module.exports = sum;

// numbers is an array full of numbers
// let's find the largest and return it
// i.e. [2,3,5,1,4] => 5
function largest(numbers) {
return numbers.reduce((accumulator, currentValue) => {
if (accumulator > currentValue) {
return accumulator;
} else {
return currentValue;
}
}, 1);
}
module.exports = largest;

// numbers is an array full of numbers
// let's find the largest and return it
// i.e. [2,3,5,1,4] => 5
function largest(numbers) {
return numbers.reduce((accumulator, currentValue) => {
if (accumulator > currentValue) {
return accumulator;
} else {
return currentValue;
}
}, 1);
}
module.exports = largest;

// numbers is an array full of numbers
// let's remove any duplicates and return it
// i.e. [2,2,3,5,1,3,4] => [2,3,5,1,4]
function removeDuplicates(numbers) {
return numbers.reduce((accumulator, currentValue) => {
if (-1 === accumulator.indexOf(currentValue)) {
accumulator.push(currentValue);
}
return accumulator;
}, []);
}
module.exports = removeDuplicates;

// food is an array full of food objects
// let's group them by "type" and return them
function group(foods) {
return foods.reduce((accumulator, currentValue) => {
accumulator[currentValue.type] = accumulator[currentValue.type] || [];
accumulator[currentValue.type].push(currentValue.food);
return accumulator;
}, {});
}
module.exports = group;

// numbers is an array full of integers
// let's figure if all the numbers are unique
// i.e. [1,2,3,1] => false
// [1,2,3] => true
function allUnique(numbers) {
return numbers.reduce((accumulator, currentValue, index) => {
if (!accumulator) {
return false;
}
c = numbers.indexOf(currentValue);
return (c === index);
}, true);
}
module.exports = allUnique;


function factorial(n) {
if (n === 1) {
return 1;
}
return n * factorial(n - 1);
}
module.exports = factorial;

function factorial(n) {
if (n === 1) {
return 1;
}
return n * factorial(n - 1);
}
module.exports = factorial;

function factorial(n) {
if (n === 1) {
return 1;
}
return n * factorial(n - 1);
}
module.exports = factorial;

function walk(node) {
if (node.next) {
return walk(node.next);
} else {
return node;
}
}
module.exports = walk;

function walk(node) {
if (node.next) {
return walk(node.next);
} else {
return node;
}
}
module.exports = walk;


const { MAX_STACK_SIZE } = require('./config');
class Stack {
constructor() {
this.items = [];
}
push(item) {
if (this.items.length >= MAX_STACK_SIZE) {
throw new Error("size Overflow error");
}
this.items.push(item);
}
pop() {
if (this.items.length === 0) {
throw new Error("0 item error");
}
return this.items.pop();
}
isEmpty() {
return (this.items.length === 0);
}
peek() {
if (this.isEmpty()) {
return;
}
return this.items[this.items.length - 1];
}
}
module.exports = Stack;

const { MAX_STACK_SIZE } = require('./config');
class Stack {
constructor() {
this.items = [];
}
push(item) {
if (this.items.length >= MAX_STACK_SIZE) {
throw new Error("size Overflow error");
}
this.items.push(item);
}
pop() {
if (this.items.length === 0) {
throw new Error("0 item error");
}
return this.items.pop();
}
isEmpty() {
return (this.items.length === 0);
}
peek() {
if (this.isEmpty()) {
return;
}
return this.items[this.items.length - 1];
}
}
module.exports = Stack;

const { MAX_STACK_SIZE } = require('./config');
class Stack {
constructor() {
this.items = [];
}
push(item) {
if (this.items.length >= MAX_STACK_SIZE) {
throw new Error("size Overflow error");
}
this.items.push(item);
}
pop() {
if (this.items.length === 0) {
throw new Error("0 item error");
}
return this.items.pop();
}
isEmpty() {
return (this.items.length === 0);
}
peek() {
if (this.isEmpty()) {
return;
}
return this.items[this.items.length - 1];
}
}
module.exports = Stack;

const Stack = require('./Stack');
class OperationManager {
constructor() {
this.operations = new Stack();
this.undos = new Stack();
}
addOperation(operation) {
this.operations.push(operation);
}
undo() {
this.undos.push(this.operations.pop());
}
redo() {
this.operations.push(this.undos.pop());
}
redoAll() {
while (!this.undos.isEmpty()) {
this.operations.push(this.undos.pop());
}
}
}
module.exports = OperationManager;

const Stack = require('./Stack');
class OperationManager {
constructor() {
this.operations = new Stack();
this.undos = new Stack();
}
addOperation(operation) {
this.operations.push(operation);
}
undo() {
this.undos.push(this.operations.pop());
}
redo() {
this.operations.push(this.undos.pop());
}
redoAll() {
while (!this.undos.isEmpty()) {
this.operations.push(this.undos.pop());
}
}
}
module.exports = OperationManager;

const Stack = require('./Stack');
class OperationManager {
constructor() {
this.operations = new Stack();
this.undos = new Stack();
}
addOperation(operation) {
this.operations.push(operation);
}
undo() {
this.undos.push(this.operations.pop());
}
redo() {
this.operations.push(this.undos.pop());
}
redoAll() {
while (!this.undos.isEmpty()) {
this.operations.push(this.undos.pop());
}
}
}
module.exports = OperationManager;


class Node {
constructor(data) {
this.data = data;
this.next = null;
}
}
module.exports = Node;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;
class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;


// retrieve a prop that is deeply nested within objects
// i.e. { prop: { prop: { prop: 3 }}} => 3
function deepRetrieval(obj) {
if ("object" === typeof (obj.prop)) {
return deepRetrieval(obj.prop);
}
return obj.prop;
}
module.exports = deepRetrieval;
vậy là kết thúc phần


function sortUp(array) {
return array.sort(function comparison(a, b) {
if (b < a) {
return 1;
}
if (a < b) {
return -1;
}
return 0;
});
}
module.exports = sortUp;

function sortDown(array) {
return array.sort(function comparison(a, b) {
if (b < a) {
return -1;
}
if (a < b) {
return 1;
}
return 0;
});
}
module.exports = sortDown;

function sortStringsUp(array) {
return array.sort(function comparison(a, b) {
return a.localeCompare(b);
});
}
module.exports = sortStringsUp;

function sortStringsDown(array) {
return array.sort(function comparison(a, b) {
if (a.localeCompare(b) === 1) {
return -1;
}
if (a.localeCompare(b) === -1) {
return 1;
}
return a.localeCompare(b);
});
}
module.exports = sortStringsDown;

function sortStudents(students) {
return students.sort(function comparison(a, b) {
if (a.graduated !== b.graduated) {
if (a.graduated) {
return -1;
} else {
return 1;
}
}
if (a.grade > b.grade) {
return -1;
}
if (a.grade < b.grade) {
return 1;
}
return 0;
});
}
module.exports = sortStudents;

const MONTHS = [
'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
];
function sortByMonth(events) {
return events.sort(function comparison(a, b) {
let ai = MONTHS.indexOf(a.month);
let bi = MONTHS.indexOf(b.month);
if (ai < bi) {
return -1;
}
if (ai > bi) {
return 1;
}
return 0;
});
}
module.exports = sortByMonth;


function plusOne(arr) {
return arr.map(function (x) {
return (x + 1);
});
}
module.exports = plusOne;

function squareRoot(arr) {
return arr.map(function (x) {
return Math.sqrt(x);
});
}
module.exports = squareRoot;

/**
* Given a number n, square it.
*
* @param {number} n
* @return {number} n squared
*/
function squared(n) {
return (n * n);
}
module.exports = squared;

const squared = require('./squared');
function squaredMap(arr) {
return arr.map(squared);
}
module.exports = squaredMap;

function addScore(players) {
let i = 0;
return players.map(function (player) {
i++;
let one = player;
if (i < 4) {
one.score = one.score + 10;
}
return one;
});
}
module.exports = addScore;

function addScore(players) {
let i = 0;
return players.map(function (player) {
i++;
let one = player;
if (i < 4) {
one.score = one.score + 10;
}
return one;
});
}
module.exports = addScore;


function lessThanFive(array) {
return array.filter(function (e) {
return (e < 5);
});
}
module.exports = lessThanFive;

function onlyTrue(array) {
return array.filter(function (e) {
return e;
});
}
module.exports = onlyTrue;

function shortStrings(array) {
return array.filter(function (e) {
return (e.length <= 3);
});
}
module.exports = shortStrings;

function topStudents(array) {
return array.filter(function (e) {
return (e.grade >= 90);
});
}
module.exports = topStudents;

function firstThree(array) {
let i = 0;
return array.filter(function (e) {
i++;
if (i < 4) {
return true;
} else {
return false;
}
});
}
module.exports = firstThree;

function unique(array) {
let a = [];
return array.filter(function (e) {
if (a.indexOf(e) === -1) {
a.push(e);
return true;
}
return false;
});
}
module.exports = unique;


// numbers is an array full of numbers
// let's add all the numbers and return the sum
// i.e. [1,2,3,4,5] => 15
function sum(numbers) {
return numbers.reduce((accumulator, currentValue) => {
accumulator = accumulator + currentValue;
return accumulator;
});
}
module.exports = sum;

// numbers is an array full of numbers
// let's find the largest and return it
// i.e. [2,3,5,1,4] => 5
function largest(numbers) {
return numbers.reduce((accumulator, currentValue) => {
if (accumulator > currentValue) {
return accumulator;
} else {
return currentValue;
}
}, 1);
}
module.exports = largest;

// numbers is an array full of numbers
// let's find the largest and return it
// i.e. [2,3,5,1,4] => 5
function largest(numbers) {
return numbers.reduce((accumulator, currentValue) => {
if (accumulator > currentValue) {
return accumulator;
} else {
return currentValue;
}
}, 1);
}
module.exports = largest;

// numbers is an array full of numbers
// let's remove any duplicates and return it
// i.e. [2,2,3,5,1,3,4] => [2,3,5,1,4]
function removeDuplicates(numbers) {
return numbers.reduce((accumulator, currentValue) => {
if (-1 === accumulator.indexOf(currentValue)) {
accumulator.push(currentValue);
}
return accumulator;
}, []);
}
module.exports = removeDuplicates;

// food is an array full of food objects
// let's group them by "type" and return them
function group(foods) {
return foods.reduce((accumulator, currentValue) => {
accumulator[currentValue.type] = accumulator[currentValue.type] || [];
accumulator[currentValue.type].push(currentValue.food);
return accumulator;
}, {});
}
module.exports = group;

// numbers is an array full of integers
// let's figure if all the numbers are unique
// i.e. [1,2,3,1] => false
// [1,2,3] => true
function allUnique(numbers) {
return numbers.reduce((accumulator, currentValue, index) => {
if (!accumulator) {
return false;
}
c = numbers.indexOf(currentValue);
return (c === index);
}, true);
}
module.exports = allUnique;


function factorial(n) {
if (n === 1) {
return 1;
}
return n * factorial(n - 1);
}
module.exports = factorial;

function factorial(n) {
if (n === 1) {
return 1;
}
return n * factorial(n - 1);
}
module.exports = factorial;

function factorial(n) {
if (n === 1) {
return 1;
}
return n * factorial(n - 1);
}
module.exports = factorial;

function walk(node) {
if (node.next) {
return walk(node.next);
} else {
return node;
}
}
module.exports = walk;

function walk(node) {
if (node.next) {
return walk(node.next);
} else {
return node;
}
}
module.exports = walk;


const { MAX_STACK_SIZE } = require('./config');
class Stack {
constructor() {
this.items = [];
}
push(item) {
if (this.items.length >= MAX_STACK_SIZE) {
throw new Error("size Overflow error");
}
this.items.push(item);
}
pop() {
if (this.items.length === 0) {
throw new Error("0 item error");
}
return this.items.pop();
}
isEmpty() {
return (this.items.length === 0);
}
peek() {
if (this.isEmpty()) {
return;
}
return this.items[this.items.length - 1];
}
}
module.exports = Stack;

const { MAX_STACK_SIZE } = require('./config');
class Stack {
constructor() {
this.items = [];
}
push(item) {
if (this.items.length >= MAX_STACK_SIZE) {
throw new Error("size Overflow error");
}
this.items.push(item);
}
pop() {
if (this.items.length === 0) {
throw new Error("0 item error");
}
return this.items.pop();
}
isEmpty() {
return (this.items.length === 0);
}
peek() {
if (this.isEmpty()) {
return;
}
return this.items[this.items.length - 1];
}
}
module.exports = Stack;

const { MAX_STACK_SIZE } = require('./config');
class Stack {
constructor() {
this.items = [];
}
push(item) {
if (this.items.length >= MAX_STACK_SIZE) {
throw new Error("size Overflow error");
}
this.items.push(item);
}
pop() {
if (this.items.length === 0) {
throw new Error("0 item error");
}
return this.items.pop();
}
isEmpty() {
return (this.items.length === 0);
}
peek() {
if (this.isEmpty()) {
return;
}
return this.items[this.items.length - 1];
}
}
module.exports = Stack;

const Stack = require('./Stack');
class OperationManager {
constructor() {
this.operations = new Stack();
this.undos = new Stack();
}
addOperation(operation) {
this.operations.push(operation);
}
undo() {
this.undos.push(this.operations.pop());
}
redo() {
this.operations.push(this.undos.pop());
}
redoAll() {
while (!this.undos.isEmpty()) {
this.operations.push(this.undos.pop());
}
}
}
module.exports = OperationManager;

const Stack = require('./Stack');
class OperationManager {
constructor() {
this.operations = new Stack();
this.undos = new Stack();
}
addOperation(operation) {
this.operations.push(operation);
}
undo() {
this.undos.push(this.operations.pop());
}
redo() {
this.operations.push(this.undos.pop());
}
redoAll() {
while (!this.undos.isEmpty()) {
this.operations.push(this.undos.pop());
}
}
}
module.exports = OperationManager;

const Stack = require('./Stack');
class OperationManager {
constructor() {
this.operations = new Stack();
this.undos = new Stack();
}
addOperation(operation) {
this.operations.push(operation);
}
undo() {
this.undos.push(this.operations.pop());
}
redo() {
this.operations.push(this.undos.pop());
}
redoAll() {
while (!this.undos.isEmpty()) {
this.operations.push(this.undos.pop());
}
}
}
module.exports = OperationManager;


class Node {
constructor(data) {
this.data = data;
this.next = null;
}
}
module.exports = Node;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;
class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;

class LinkedList {
constructor() {
this.head = null;
}
addFirst(node) {
node.next = this.head;
this.head = node;
}
addLast(node) {
if (this.head === null) {
this.head = node;
return;
}
let last = this.head;
while (last.next !== null) {
last = last.next;
}
last.next = node;
}
indexOf(node) {
let i = 0;
for (let p = this.head; p !== null; p = p.next) {
if (node === p) {
return i;
}
i = i + 1;
}
return -1;
}
removeAt(index) {
if (this.head === null) {
return;
}
if (index === 0) {
this.head = this.head.next;
return;
}
let i = 1;
let p = this.head;
let n = this.head.next;
while (n) {
if (i === index) {
p.next = n.next;
return;
}
p = p.next;
n = n.next;
i++;
}
}
}
module.exports = LinkedList;


// retrieve a prop that is deeply nested within objects
// i.e. { prop: { prop: { prop: 3 }}} => 3
function deepRetrieval(obj) {
if ("object" === typeof (obj.prop)) {
return deepRetrieval(obj.prop);
}
return obj.prop;
}
module.exports = deepRetrieval;
vậy là kết thúc phần
No activity yet