How to link input from HTML text field to Javascript

Hello guys,
I’m trying to link the input from my HTML text field to my Javascript function argument.
This is my code so far:

javascript code:

function checkNum(num) {
  let ascend = num.toString().split('').sort(function(a, b){return a-b}).join('');
  let descend = num.toString().split('').sort(function(a, b){return b-a}).join('');
  let result = descend - ascend;
  return result;
}
 function Kaprekar(num) {
   
var count = 0;
let reverseNum = num.toString().split('').reverse().join('');
  let n  = num.toString();
  while (num !== 6174 && num !==0 && num >= 1000 && num < 10000 && n !== reverseNum) {
   num = checkNum(num);
    count += 1;
  }
  document.getElementById("txtresult").value = count;
   
}

let Kaprekar(num) = parseInt(document.getElementById("Text1").value);

my HTML code:

<div id = "main">
  <input type="text"  id="Text1" value="" name="TextBox1">
  <p>Click the button to count</p>
  
  <button  onclick="Kaprekar(num)">Check</button>
  <div id >
    <input type="text" id="txtresult" name="TextBox3">
  </div> 
</div>

I want to call Kaprekar (num) from the html input text field. i have tried " let Kaprekar(num) = parseInt(document.getElementById(“Text1”).value);
". but its not working

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

The goal of my Kapreka function is to take a non-consecutive four-digit number and do descend and ascend, subtract ascend from descend with the aid of the checkNum (). if the result is not equal to 6174, the operation start again until final result is 6174. The number of count is displayed.
but my issue is, i want to input the argument in kapreka which will a be number from html text input.

do you mean i should specify the “onclick” attribute to the text input?

the function of the button is just to perform Kapreka() operation when you input a value in the text input area.
you can check my codepen: https://codepen.io/Benony/pen/zJLrRx

Oh! i get what you meant now. Thank you so much
it worked