Question: Create only one JavaScript file which must be called STUDENT_ID-functions.js . All the functions you implement must be placed in STUDENT_ID-functions.js and you are not

  • Create only one JavaScript file which must be called STUDENT_ID-functions.js.

  • All the functions you implement must be placed in STUDENT_ID-functions.js and you are not allowed to use any external file or library. Using an extra file or library will produce a zero mark for your assignment.

  • Based on the last two digits of your student id, you are required to implement the following function


Student ID last two digits: 00 to 50

  1. Write a function which returns the sum of the values for each parameter it receives. You’ll need to use the JavaScript arguments object to determine the number of parameters.

  1. Write a function which returns the calling string value converted to lowercase. //function("ALPHABET"); // return "alphabet"

  1. Write a function that returns a subset of a string between one index and another. function(str, indexStart, indexEnd) Example

((‘abcd’,1,10) return ‘bcd’) Example 2 (‘abcd’,0 ,1) return ‘ab’) (similar built-in function substring or substr).

  1. Write a function that returns a new string containing all matches. Each match is then replaced by replacement characters. function(str, charToChange, charToReplace)

Example ((‘abc’,’a’,’X’) return Xbc

  1. Write a function that returns an index of the receiving string for the first occurrence of the specified character. Start the search with the fromIndex parameter. Returns -1 if the value is not found. function(str,searchChar,fromIndex) (similar built-in function indexof)

  1. Write a function which removes whitespace from both ends of the receiving string. Whitespace in this context is all whitespace characters (spaces, tabs, and newlines.) function(" value\t ") //return "value"

  1. Write a function which splits the receiving string parameter into an array of strings by separating the string into substrings and return the array. function (stringToSplit, separator) Example (‘a|b|c’, ‘|’ return [‘a’,’b’,’c’], (bcAbd, ‘A’, return [‘bc’, ‘bd’], (bacd, ‘X’ return [‘b’,’a’,’c’,’d’]) (similar built-in function split)

  1. The trimRight() method removes whitespace from the right end of a string. Whitespace in this context is all the whitespace characters (spaces, tabs, and newlines.) function(" value\t ") //return " value"

  1. Write a function to return a unique concatenated array from 2 arrays.

//function([1,2],[2,4]) //return [1,2,4]’, (Note: similar functionality as Array.concat )

  1. Write a function that accepts an array and a value to find and return the first element that is bigger than the given value.

//function([5,15,4],6) //return 15’, (Note: similar functionality as

Array.find )

Step by Step Solution

3.30 Rating (138 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer function sum var result0 forvar i0 i if argumentsi00 argum... View full answer

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

Document Format (1 attachment)

Word file Icon

628b7dbf5d3dd_Assignment1w2019MSword.docx

120 KBs Word File

Students Have Also Explored These Related Databases Questions!