+ 4
šŸ”„šŸ…³šŸ…“šŸ†… šŸ†‚šŸ…·šŸ…øšŸ†…šŸ…½šŸ…°šŸ…½šŸ…³šŸ…°šŸ…½ šŸ…¼šŸ…øšŸ†‚šŸ…·šŸ†šŸ…°šŸ”„ First issue js variable is not accessible in html like that. Also your calling function in html doesn't have parameter. Second issue just call function in html onclick event. Third issue querySelector should get value using # because sqrt is a id. Also you should get value by using .value with querySelector. string "js" is not coming because of comma (,) which is not work in alert. this only work in console.log Suggestions:- no need to write js code in html instead you can all do in JS. Do this: function sqrt() { let square = document.querySelector("#sqrt").value; let sqrt1 = square * square; alert('Square of ' + square + ' is: ' + sqrt1) } https://code.sololearn.com/WDNXpYyiU6wm/?ref=app
5th Feb 2022, 3:52 AM
AĶ¢J
AĶ¢J - avatar