JS copy textarea button

Hi guys, i’m a grade 9 student and struggling with my small JS project. my teacher wants me to create a password generator. he wants me to create a Copy button that copies the random password that will display the word “copied” and display “field is empty” when blank. so far this is what i have

<code>
</style>
SEMrush

</head>
<script language=”javascript” type=”text/javascript”>
function randomString() {
var chars = “00112233445566778899AaBbCcDdEdFfGgHhIiJjKkLLMmNnOoPpQqRrSsTtUuVvWwXxYyZz”;
var string_length = 8;
var randomstring = ”;
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
document.randform.randomfield.value = randomstring;
}

// Start copy button here

function copy() {
let textarea = document.getElementById(“myInput”);
textarea.select();
document.execCommand(“copy”);
}

// END copy button

</script>

<form name=”randform” align=”center”>
<input type=”button”
style=”font-family:Consolas;color:#FFFFFF”
class=”button button1″
value=”Generate”
onClick=”randomString();”>&nbsp;
<input type=”text”
id=”myInput”
name=”randomfield”
value=””
style=”color:blue; padding: 12px 16px; font-size:20px; font-family:Consolas; font-weight:bold; background:#FCF4A3; width: 10%;”>&nbsp

<input type=”button”
style=”font-family:Consolas;color:#FFFFFF”
class=”button copybtn”
value=”COPY”
onClick=”copy(‘myInput’);”>&nbsp;

</form>
</code>