JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" value="start1" id="start1">
<input type="button" value="stop1" id="stop1">

JavaScript

var startButton1 = document.getElementById("start1");
var stopButton1 = document.getElementById("stop1");

function makeOsc(){

	var context1 = new AudioContext();
	var oscillator1 = context1.createOscillator();

	oscillator1.connect(context1.destination)

	oscillator1.onended = function() {
		alert("ended");
		makeOsc();
	}

	startButton1.addEventListener('click', function() {
		oscillator1.start();
	});

	stopButton1.addEventListener('click', function() {
		oscillator1.stop();
		
	});

}

makeOsc();