Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tasksPlanner(arr) {
- let tasks = arr.shift().split(' ').map(Number);
- for (let iterator of arr) {
- let [command, index, time] = iterator.split(' ');
- time = Number(time);
- index = Number(index);
- if (command === 'End') {
- break;
- }
- if (command === 'Complete') {
- complete(+index)
- }
- if (command === 'Change') {
- change(+index, time);
- }
- if(command === 'Drop'){
- drop(+index);
- }
- }
- function complete(index) {
- arr.find(function (index) {
- arr[i] = 0;
- }
- }
- function change(index, time){
- if(index >= 0 && index < tasks.length){
- tasks[index] = time;
- }}
- function drop(index){
- if(index >= 0 && index < tasks.length){
- tasks[index] = -1;
- arr.filter(index => index >= 0);
- }
- }
- console.log(arr);
- }
- tasksPlanner(['1 -1 2 3 4 5 ', 'Complete 4', 'Change 0 4', 'Drop 3', 'Count Dropped', 'End']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement