Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a JavaScript file containing 10 functions. Each function represents one step and 10 marks are assigned to each step (function). The functions you are

Create a JavaScript file containing 10 functions. Each function represents one step and 10 marks are assigned to each step (function). The functions you are creating might be very similar to a built-in function found redefined in the JavaScript language.

Each function needs to be considered as an individual problem. Focus on each function one problem at a time until all 10 functions are defined.

There are two versions of the assignment. The last two digits of your student id determine the set of steps you must implement. Check the what to implement section of this document for more details.

  • 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 functions

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.

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

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).

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

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)

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 ") //return "value"

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)

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 ") //return " value"

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 )

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 )

Do not use function

You are not allowed to use any of the built-in functions listed in the Do not usefunction section of this document. Using any of the following functions will result inzero marks for your assignment.

String built-in functions

Array built-in functions

endsWith()

concat()

includes()

copyWithin()

indexOf()

every()

lastIndexOf()

fill()

localeCompare()

filter()

match()

find()

repeat()

findIndex()

replace()

forEach()

search()

indexOf()

slice()

isArray()

split()

join()

startsWith()

lastIndexOf()

substr()

map()

substring()

pop()

toLocaleLowerCase()

push()

toLocaleUpperCase()

reduce()

toLowerCase()

reduceRight()

toString()

reverse()

toUpperCase()

shift()

trim()

slice()

some()

valueOf()

sort()

trimLeft and trimRight

splice()

toString()

unshift()

valueOf()

Step by Step Solution

3.42 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

function s... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Project management the managerial process

Authors: Eric W Larson, Clifford F. Gray

5th edition

73403342, 978-0073403342

More Books

Students also viewed these Programming questions

Question

Introduce self driving cars

Answered: 1 week ago