javascript function that takes an array of objects and one key as parameter and returns value of that key and code example

Example 1: write a bash script that accepts a text file as argument and calculates number of occurrences of each words in it and return them as key value pairs

file=/home/stefan/ooxml1.txt
for word in $(sed 's/[^A-Za-z]/ /g' $file | tr " " "\n" | sort -u)
do
  echo -n "$word "
  grep -c $word $file
done | sort -k2 -n

Example 2: write a function that takes in 2 arrays , merges them together an then return the new array sorted

// const twoArraysSorted = (arr) => {
//     let copy = [...];
//     copy.sort((a,b) => a-b).map(el=> el*2)
//     return arr
// }

Tags:

Misc Example