JavaScript
Write a function named "sort_by_length" that takes a list/array of strings as a parameter and sorts the strings by their length
function sort_by_length(strings) {
strings.sort(function (n1, n2) {
if (n1.length < n2.length) return -1;
if (n1.length > n2.length) return 1;
return 0;
});
}
strings = ['hi', 'hello', 'a', 'how', 'are', 'you?'];
console.log("original list:" + strings);
sort_by_length(strings);
console.log("sorted list:" + strings);
JavaScript Write a function named "sort_by_length" that takes a list/array of strings as a parameter and...
Python: Write a function named "sort_by_length" that takes a list/array of strings as a parameter and sorts the strings by their length
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 method named avgLength which takes an array of Strings as an input parameter and returns a double. The method should calculate and return the average length of all the strings in the array (in java langauge)
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)
javascript-Write a function named "json_average" that takes a JSON formatted string as a parameter in the format of an array of objects where each object has keys "mass", "density", "temperature", and "velocity" and each key maps to a floating point number. This function should return the average "velocity" of all the objects in the array as a JSON string in the format {"velocity": }
write a function firstLetterWords(words) that takes as a parameter a list of strings named words and returns a dictionary with lower case letters as keys. But now associate with each key the list of the words in words that begin with that letter. For example, if the list is ['ant', 'bee', 'armadillo', 'dog', 'cat'], then your function should return the dictionary {'a': ['ant', 'armadillo'], 'b': ['bee'], 'c': ['cat'], 'd': ['dog']}.
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.
Python: 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"
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.
In Javascript: Write a function named "categorize" that takes a string as a parameter and returns "short" if the input has less than 6 characters, "medium" if the input has greater than or equal to 6 but less than 7, and returns "long" if the input has greater than or equal to 7 characters. Thanks