This is a follow-up to my previous post Adding JS to the checkout, which was answered nicely here.
It works fine, but now I have a problem that I want to add and call multiple JS functions, so I tried:
define([
'jquery',
], function($){
var hello = function()
{
alert('Bonjour Amir');
}
var print = function()
{
console.log('asdfgh');
}
return hello && print;
});
And in the template I call it like:
<script type="text/javascript">
require(['jquery', 'checkoutjs'], function($, hello, print) {
hello();
print();
});
</script>
But I get an error:
Uncaught TypeError: print is not a function
However, hello
function is the one that does not execute.
I am very unfamiliar with this structure, and with JS in general.