How to display previous value of a given value from an array in javascript

Issue

This Content is from Stack Overflow. Question asked by Amir Bhutta

How we can display the previous value of given value while value is given from an array and we should display the previous value of it

var theArray = [1,2,3,4,5,6,7,8,9,14,15];
const findValue = (arr, input) => {
  // to do 
}
findValue(theArray , 15)

When we give 15 in input then output would be 14



Solution

Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?