I ran into such a problem, in my App, I have a variable that contains productId, Also I have a function which returns productId, I wonder if that is possible to pass productId
function into addToCard()
function as a parameter and return value, I am trying to get a similar result addToCard('223343445')
, It is possible to achieve this result? Thanks
let singleProductId = '223343445'
productId(singleProductId)
function productId(parameter){
return parameter
}
function addToCard(param){
console.log(`${param} added to the card`)
}
<button onclick=addToCard(productId())>add to cart</button>