Functions and javascript

This the java trigger event function

Here is the script

function bubble_fn_alarm(){return}

// Array to store selected alert times (in HH:MM format)
var selectedAlertTimes = [‘Current User’s ADtimeone’, ‘Current User’s ADtimetwo’];

// Function to check and display alerts based on selected times
function checkAlerts() {
var currentTime = new Date();
var currentHour = currentTime.getHours();
var currentMinute = currentTime.getMinutes();

// Format current time as HH:MM
var formattedCurrentTime = (‘0’ + currentHour).slice(-2) + ‘:’ + (‘0’ + currentMinute).slice(-2);

// Check if the current time matches any selected alert time
if (selectedAlertTimes.includes(formattedCurrentTime)) {alert(‘Alert! It is ’ + formattedCurrentTime + ’ - time for an alert!’);}}

// Call the checkAlerts function every second
setInterval(checkAlerts, 1000);

Here is the alert from the javascript on the design page.

Your help would be much appreciated.

Once I get one correct I should be fine.

Here is my updated script

// Array to store selected alert times (in HH:MM format)
var selectedAlertTimes = [‘04:25’, ‘19:39’];

// Function to display the alert message
function bubble_fn_alarm(message) {
console.log(message); // You can replace this with your own logic to display the alert
}

// Function to check and display alerts based on selected times
function checkAlerts() {
var currentTime = new Date();
var currentHour = currentTime.getHours();
var currentMinute = currentTime.getMinutes();

// Format current time as HH:MM
var formattedCurrentTime = (‘0’ + currentHour).slice(-2) + ‘:’ + (‘0’ + currentMinute).slice(-2);

// Check if the current time matches any selected alert time
if (selectedAlertTimes.includes(formattedCurrentTime)) {
var alertMessage = ‘Alert! It is ’ + formattedCurrentTime + ’ - time for an alert!’;
bubble_fn_alarm(true);
}
}

// Call the checkAlerts function every second
setInterval(checkAlerts, 1000);