Ultrasonic Sensor Variable

I'm new to javascript/Arduino and I am trying to make a simple device that detects the distance between a solid object using an ultrasonic sensor. And if the distance is too large a red LED turns on. How am I supposed to create a program that reads data from the serial monitor and decided whether the value is too big or not?
Thanks

Welcome to the forums. Arduino is C/C++, not javascript, but anyway....

Read this tutorial by Robin2 Serial Input Basics to learn how to do it.

How am I supposed to create a program that reads data from the serial monitor

What data are you sending from the Serial Monitor application? Everything the Arduino needs to know should be coming from the ultrasonic sensor. Unless, for some strange reason, you have connected the ultrasonic sensor to the PC...

What data are you sending from the Serial Monitor application? Everything the Arduino needs to know should be coming from the ultrasonic sensor.

Maybe the threshold value needs to be set by the user from the monitor, rather than being hard-coded?