Javascript function that takes an array parameter and returns an array value. The assumption is that the array is an integer array. The returned array should be composed of the square of the elements in the array parameter for the corresponding position.
function sayHello(arr) //function taking array as parameter and
returning array result
{result=[];//array to store result
//calculating square of each element and storing in the result
array
for (i=0; i<arr.length; i++){
sqr=Math.pow(arr[i],2);
result.push(sqr);
}
return result; //returning result array
}
var x = [1,2,3]; //intializing x array
var y=sayHello(x); //calling function and passing array x
//printing resulting array in alert
for (i=0; i<y.length; i++){
alert(y[i]);
}
//Please let me know in case of any doubt,Thanks.
Javascript function that takes an array parameter and returns an array value. The assumption is that...
create a javascript function named sumBeyond that takes in an array of numbers and returns the summation of the values in the array that are greater than (but not including) 42. If there are no values greater than 42, the function should return 0. example- sumBeyond([2,85,932,0,7,-5,0,32]) must return 1017
in javascript Write a function named "sort_by_average_rating" that takes a list/array of key-value stores as a parameter where each key-value store has keys "ratings", "budget", and "box_office" where budget and box_office are integers and ratings is a list of integers. Sort the input based on the average of the values in "ratings"
Write a function that takes an array of C-strings as a parameter and the number of elements currently stored in the array, and returns a single C-string pointer that is the concatenation of all C-strings in the array. Note: The function must take 2 parameters and return "char *". Any other ways will cause some deduction of points.
Given an array and a starting position write a function replaceFromN, that takes an integer array 'array', the size of the array size and a starting positions 'n' as parameters and replaces the elements starting from that index onward with the sequence 1,2,3,... The function returns nothing. void replaceFromN(int array[], int size, int n) For example, given array= {15,12,4,9,2,3} n =2 the function should modify array to be {15,12,1,2,3,4}
create a javascript function named bbqFood that takes in an object and returns an array. The input object will have strings naming party foods as the key and the numbers of people that each key will feed as its values. return an array containing all of the keys whose values are greater than 10, menaing it will feed more than 10 people. example bbqfood(['taco':15, 'hamburger':6,'pasta':42,'fruit':23}) must return ['taco','pasta','fruit']
use javascript please Complete the function below using recursion. Assume the parameter is a positive integer. The function will return an array that contains all of the numbers from 1 up to the parameter in consecutive order. For example, if the parameter is the value 5 then the return value should be the array [1, 2, 3,4 function makeSequence(value) t\ please use recursion thank von
1- takes a 1D integer array arr as a parameter and returns a boolean value. 2- The method returns true if the argument array contains two distinct values such that the sum of those two values is equal to the first element of the array arr. Otherwise, it returns false. 3- Assume that arr contains only positive integers (greater than 0). Sample runs provided below. 4- Sample runs provided below. 5- Complete and place your code in the Question 3...
(C++) Write a function, insertAt, that takes four parameters: an array of integers, the number of elements in the array, an integer (say, insertItem), and an integer (say, index). The function should insert insertItem in the array provided at the position specified by index. If index is out of range, output the following: Position of the item to be inserted is out of range or if the index is negative: Position of the item to be inserted must be nonnegative...
Write a function named "find_key" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the string "focus" is in the input as a key, false otherwise(javascript)
Write a function that gets an array as a parameter, sorts it in a descending fashion and returns the number of elements that did not change position in the sort (they were originally in the right position). int sortDESC(int* myArray, int size) if array = { 2, 3, 1, 0, -1} after calling the function the array should become {-1, 0, 1, 2 , 3 } and the function should return 1 (only one element has not changed place in...