Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

106
Vistas
I need help adding a button to run a function in my JavaScript

I need help with my JavaScript, when the user clicks the button i want to prompt the user to enter a score (0-100) then return a grade based on that score (e.g- 100-80=A, 79-60=B ... <30=F) By the way please explain how and why each step is done because i'm quite dumb, thanks.

<!DOCTYPE html>
<html>

<head>

<title>Marks to Grade Conversion</title>

<style>
h1 {font-family:serif; font-size:36px; color:#ff0000; text-align:center}
h2 {font-family:sans-serif; font-size:24px; color:#000000; text-align:center}
body {background-color:#FFCC00}
</style>

</head>

<body>
    
    <h2>Faculty of Computer science</h2><br>
    <h1>End of year module test results Mark to Grade utility</h1><br><br>
    <h2>Click the button to enter the Mark and display the Grade</h2><br>
  
  <h2><button style="font-size:24px; height:50px; width:300px"; onClick="ConvertMark()"> Click to enter the mark </button></h2><br>
  
<h1 id="display grade here"></h1></b></td>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

pretty basic. write your function, get input, convert, display result

function ConvertMark(){

let display = document.getElementById('display')

let grade = prompt("Enter grade: ")
let alpha = "";

if (grade >= 90)alpha = 'A'
else if(grade >= 80)alpha = 'B'
else if(grade >= 70)alpha = 'C'
else if(grade >=60)alpha = 'D'
else alpha = 'F'

display.innerHTML = alpha


}
h1 {font-family:serif; font-size:36px; color:#ff0000; text-align:center}
h2 {font-family:sans-serif; font-size:24px; color:#000000; text-align:center}
body {background-color:#FFCC00}
    
    <h2>Faculty of Computer science</h2><br>
    <h1>End of year module test results Mark to Grade utility</h1><br><br>
    <h2>Click the button to enter the Mark and display the Grade</h2><br>
  
  <h2><button style="font-size:24px; height:50px; width:300px"; onClick="ConvertMark()"> Click to enter the mark </button></h2><br>
  
<h1 id="display"></h1>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda