/*
Given an index and an array, return the value of the array with the given index.

Examples
valueAt([1, 2, 3, 4, 5, 6], 10 / 2) ➞ 6

valueAt([1, 2, 3, 4, 5, 6], 8.0 / 2) ➞ 5

valueAt([1, 2, 3, 4], 6.535355314 / 2) ➞ 4
If the index is an invalid one, give an appropriate error message, instead of printing “undefined”
*/

function valueAt(arr, i) {
  if (i >= arr.length){
  return "Index >= Array length, therefore arr[i] is undefined.";
  } else {
	return arr[Math.floor(i)];
    
  }
	
};
console.log(valueAt([1, 2, 3, 4, 5, 6], 10 / 2));
console.log(valueAt([1, 2, 3, 4, 5, 6], 8.0 / 2));
console.log(valueAt([1, 2, 3, 4], 6.535355314 / 2));
console.log(valueAt([0, 9, 0, 0, "lol", 0], 4));
console.log(valueAt([1, 2, 3, 4, 5, 6.785], 14.9 / 2)); 
by