How to set translations in javascripts for my plugin?

The WordPress way to do this is the wp_localize_script() function.

When you enqueue a script, also add a call to wp_localize_script():

wp_register_script( 'my-script', 'path/to/script.js' );
wp_localize_script( 'my-script', 'myScript', array(
    'msg_must_match' => __( 'Message must match', 'my-plugin-domain' ),
) );

This creates a global JavaScript object called myScript that will contain the keys and values passed as an array in the 3rd argument. So you can pass in strings using the WordPress translation functions, which will get translated just like any other string in your plugin.

Then in your script you can use those values for your strings:

inputRepeat.setCustomValidity( myScript.msg_must_match );