Question: Can anyone help me with this? TASK In the tasklist library file (library_tasklist.js), modify the displaySortedTaskList function so it checks the number of arguments that

Can anyone help me with this?

TASK

In the tasklist library file (library_tasklist.js), modify the displaySortedTaskList function so it checks the number of arguments that are passed to it. If three arguments are passed, the function should be done. Otherwise, this function should create and throw an error object with the custom message shown above.

Can anyone help me with this? TASK In the tasklist library file

HTML:

Ch10 Task Manager

Task Manager

CSS:

body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; background-color: white; width: 725px; margin: 0 auto; border: 3px solid blue; padding: 0 2em 1em; } h1 { font-size: 150%; color: blue; margin-bottom: .5em; } label { float: left; width: 8em; } input { width: 20em; margin-right: 1em; margin-bottom: 1em; } #tasks { float: right; width: 25em; margin: 0 0 .5em; padding: 1em; border: 2px solid black; } #tasks a { margin-right: 0.5em; } #message { color: red; } p { margin: 0; padding-bottom: .5em; } .clear { clear: both; }

TASK LIST JS:

"use strict"; var $ = function(id) { return document.getElementById(id); }; var tasks = [];

var displayTaskList = function() { // get tasks from storage if (tasks.length === 0) { tasks = getStorage("tasks_10"); } // display sorted tasks with delete links displaySortedTaskList(tasks, $("tasks"), deleteFromTaskList); //displaySortedTaskList(tasks); // set focus on task text box $("task").focus(); };

var addToTaskList = function() { var task = $("task"); if (task.value === "") { alert("Please enter a task."); } else { tasks.push(capitalizeTask(task.value)); setStorage("tasks_10", tasks);

task.value = ""; displayTaskList(); } };

var deleteFromTaskList = function() { deleteTask(tasks, this.id); // 'this' = clicked link setStorage("tasks_10", tasks); displayTaskList(); };

var clearTaskList = function() { tasks.length = 0; clearStorage("tasks_10"); $("tasks").innerHTML = ""; $("task").focus(); };

window.onload = function() { displayTaskList(); $("add_task").onclick = addToTaskList; $("clear_tasks").onclick = clearTaskList; };

LIBRARY TASK LIST JS:

"use strict"; var sortTaskList = function(tasks) { var isArray = Array.isArray(tasks); if (isArray) { tasks.sort(); } return isArray; };

var displaySortedTaskList = function(tasks, div, handler) { var html = ""; var isArray = sortTaskList(tasks);

if (isArray) { //create and load html string from sorted array for (var i in tasks) { html = html.concat("

"); html = html.concat("Delete"); html = html.concat(tasks[i]); html = html.concat("

"); } div.innerHTML = html;

// get links, loop and add onclick event handler var links = div.getElementsByTagName("a"); for (var i = 0; i

var deleteTask = function(tasks, i) { var isArray = sortTaskList(tasks); if (isArray) { tasks.splice(i, 1); } };

var capitalizeTask = function(task) { var first = task.substring(0,1); return first.toUpperCase() + task.substring(1); };

LIBRARY STORAGE JS:

"use strict"; var getStorage = function(key) { //get string from storage or an empty string if nothing in storage var storage = localStorage.getItem(key) || ""; if (storage === "") { return []; } else { return storage.split("|"); } };

var setStorage = function(key, arr) { if (Array.isArray(arr)) { var storageString = arr.join("|"); localStorage.setItem(key, storageString); } };

var clearStorage = function(key) { localStorage.setItem(key, ""); };

MY TRY

"use strict"; var $ = function(id) { return document.getElementById(id); }; var tasks = [];

var displayTaskList = function() { base = Number(base); for (var i = 1; i = 3) { tasks = getStorage("tasks_10"); }else { alert('The displaySortedTaskList function of the tasklist library requires three arguments'); } // display sorted tasks with delete links displaySortedTaskList(tasks, $("tasks"), deleteFromTaskList); //displaySortedTaskList(tasks);

// set focus on task text box $("task").focus(); };

var addToTaskList = function() { var task = $("task"); if (task.value === "") { alert("Please enter a task."); } else { tasks.push(capitalizeTask(task.value)); setStorage("tasks_10", tasks);

task.value = ""; displayTaskList(); } };

var deleteFromTaskList = function() { deleteTask(tasks, this.id); // 'this' = clicked link setStorage("tasks_10", tasks); displayTaskList(); };

var clearTaskList = function() { tasks.length = 0; clearStorage("tasks_10"); $("tasks").innerHTML = ""; $("task").focus(); };

window.onload = function() { displayTaskList(); $("add_task").onclick = addToTaskList; $("clear_tasks").onclick = clearTaskList; };

Task Manager Task: The displaySortedTaskList function of the tasklist library requires three arguments. Add Task Clear Tasks Task Manager Task: The displaySortedTaskList function of the tasklist library requires three arguments. Add Task Clear Tasks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!