¿Cómo puedo asignar una función a ? Para mostrar un número en un intervalo Captura de pantalla Por favor, dígame, ¿cómo puedo hacer esto? Creado con React Js
function onlineCount() { Math.floor(100+480*Math.random()); } setInterval(onlineCount, 1000); function HeaderTop() { // const onlineCount = Math.floor(100+480*Math.random()) return ( <div className="header-top"> <div className="header-social"> <div className="header-online"> <div className="online-general-bar"> <div className="online-bar"></div> </div> <span>{() => onlineCount}</span>REACCIONAR
const root = ReactDOM.createRoot( document.getElementById('root') ); function tick() { const element = ( <span>{Math.floor(100 + 480 * Math.random()); setTimeout(function () { onlineCount(); }, 1000);} </span> ); root.render(element); } setInterval(tick, 1000);JAVASCRIPT PURO
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function onlineCount() { document.getElementById("mySpan").innerText = Math.floor(100 + 480 * Math.random()); setTimeout(function () { onlineCount(); }, 1000); } setTimeout(function () { onlineCount(); }, 1000); </script> </head> <body> <form id="form1"> <div> <span id="mySpan"></span> </div> </form> </body> </html>