May be the question is so clear and doesn't need any more explanation but this is examples previous primes:
The previous prime of 19 is ===> 17
The previous prime of 211 is===> 199
My failing trial
const getPreviousPrime = (number) => {
for(let i = number - 1; i >= 2; i--) {
for(let j = 2; j <= Math.sqrt(i); j++ ) {
if(i % j === 0) break
return i
}
}
}