How can a PHP beginner integrate JavaScript code into a PHP script for a WordPress blog?

To integrate JavaScript code into a PHP script for a WordPress blog, you can use the wp_enqueue_script function provided by WordPress. This function allows you to add JavaScript files to your WordPress site in a clean and organized way. Simply enqueue your JavaScript file within your PHP script using wp_enqueue_script, and WordPress will handle the rest.

function my_custom_script() {
    wp_enqueue_script('my-js-script', get_template_directory_uri() . '/js/my-script.js', array('jquery'), '1.0', true);
}

add_action('wp_enqueue_scripts', 'my_custom_script');