I would like to make a web component that simply allows me to run a simple JavaScript function. i.e. it would function the two following codes would act the same way:
<body>
<div id="sample"></div>
<script> createSample(); </script>
</body>
and
<body>
<my-web-component></my-web-component>
</body>
I've tried reading some online guides to creating web components, but I am relatively new to working in JavaScript in praticular and web environments in general, so it mostly went over my head. Is there any simpele way to do what I described? Thank you for the help!