In: Computer Science
Javascript
1. Write a function which receives four arguments (array, start, end, delimiter). Copy the array values from the start to end index separated by delimiter\'s value. function([1,2,3,4],1,3,'*') // returns 2*3*4 as string
2. Write a function to change the case of all the characters in string based on their position which matches the value of the pos parameter passed to function(str, pos [even|odd]). Example: function(‘abCd’, ‘odd’) // returns Abcd
3 Write a function which receives two arguments (array, oddOrEven) based on the value of oddOrEven (odd or even value) the function will return the sum of all the array elements that matches the type of oddOrEven value. function([1,1,2,3,4],11) // returns 5 (which is the sum of all odd numbers)
DO NOT USE THESE BUILT IN FUNCTIONS BELOW
endsWith() includes() indexOf() lastIndexOf() localeCompare() match() repeat() replace() search() slice() split() startsWith() substr() substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase() toString() toUpperCase() trim() valueOf() trimLeft and trimRight unshift() valueOf()
includes() indexOf() lastIndexOf() localeCompare() match()
repeat() replace() search() slice() split() startsWith() substr()
substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase()
toString() toUpperCase() trim() valueOf() trimLeft and trimRight
unshift() valueOf()
concat() copyWithin() every() fill() filter() find() findIndex()
forEach() indexOf() isArray() join() lastIndexOf() map() pop()
push() reduce() reduceRight() reverse() shift() slice() some()
sort() splice() toString()
function joinString(array, start, end, delim) {
if(start <= end) {
s = array[start]
i = start + 1
while(i <= end) {
s = s + delim + array[i]
i++;
}
return s
}
}
console.log(joinString([1,2,3,4],1,3,'*'))
**************************************************
Please ask each part separately, since they require quite some time
to complete and it is not possible to answer everything in this
particular answer.. Please post on separate threads, so that we can
properly answer them. Thanks!
Thanks for your question. We try our best to help you with detailed
answers, But in any case, if you need any modification or have a
query/issue with respect to above answer, Please ask that in the
comment section. We will surely try to address your query ASAP and
resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.