Reference no: EM132268435
Introduction
It's time to put all your JavaScript skills to the test to build an app combining everything you've learned about JavaScript so far. In this assignment, you are required to build 10 functions.
Goals and Outcomes
• Reverse engineering functions found in JavaScript with the intention of defining them yourself
• Write decision-making statements and control structures to solve problems
• Apply programming logic to solve basic to intermediate problems
• Testing and debugging
Description
In this assignment, you are going to 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 predefined 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.
What to implement?
• 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
1. Write a function that returns a string containing random characters where the length must be equal to the value of the parameter.
2. Write a function which returns the calling string value converted to upper case.
3. Write a function which adds the equal amount (numSpace) of whitespace (numSpace) to both ends of the receiving string.
4. Write a function to change the case of all the characters in the string (str) parameter to its opposite case (upper / lower) when the character position matches the value of the pos parameter.
5. Write a function to return the reversed version of the string it receives as an argument.
6. Write a function which combines two strings which are passed as parameters. Mix one character from each string and return the concatenated result.
7. The trimLeft() method removes whitespace from the left end of a string.
8. Write a function which removes whitespace from both ends of the receiving string.
9. Write a function to concatenate 2 arrays and return a new array.
10. Write a function that accepts an array and a value. Check every element of the given array against a given value. Return true if the array elements are bigger than the provided value.
Do not use function
You are not allowed to use any of the built-in functions listed in the Do not use function section of this document. Using any of the following functions will result in zero 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()
|
|
sort()
|
splice()
|
toString()
|
unshift()
|
valueOf()
|