Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

94
Visualizações
Making a little angular resolution calculator in JS but it returns NaN

So, I'm in an astronomy class, and don't have a scientific calculator yet, so as a side project practice sometimes I'll translate a math question that would otherwise be tedious into a JS program so it can do physics math for me (like, last week i made an escape velocity function rather than punching in math individually to calculate escape velocity for multiple objects).

This new question basically states that Arcsine of theta = lightspeed/diameter of observation point (this is the equation the prof offered, though he said for the sake of simplicity we can use 1.00 rather than 1.22 in this measure as it is more precisely known). I've designed a function to take diameter as a parameter and return the answer, but when I run it it just consoles NaN, I wonder if it's my logic or syntax that is faulting me or just poor math. I'm pretty rusty, but enjoy doing little side practices to probe into my comprehension of math equations and whatnot. If anyone felt like pointing out where I went wrong, it would help me diagnose what aspect of this process I am not retaining. I'm also like 4 drinks in and it's 1:30am tho lol this I guess is how I choose to spend my time. here goes:

let lightspeed = 3*Math.pow(10,8);

function Aungular (diameter){
    let ans1 =lightspeed/diameter;
    let ans =Math.asin(ans1);

    console.log(ans);
}

Aungular(20); // returns NaN

What am I messing up? Oh, also I have like no trig experience haha, so it's important that I diagnose early on if this is what's causing whatever I overlooked.

(I hope that this doesn't cross any boundaries -- no coding is relevant to the assignment - this is something I'm doing on my own time as a brain exercise to increase my depth of understanding for math problems and exercise practice for writing code more fluently).

Edit: I mixed placements for diameter and lightspeed, program runs if they are switched. Solved, I guess. It's always the simplest stuff that I miss haha

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda