Frequency to note name

(Assuming MIDI note names)

function frequencyToNoteNumber(f) {
        return Math.round(12 * Math.log(f / 440.0) + 69);
    }

    function noteNumberToNote(n) {
        var notes = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'],
            name = n % 12,
            octave = Math.floor(n / 12) - 1;

        return notes[name] + octave;
    }

    function frequencyToNote(f) {
        return noteNumberToNote(frequencyToNoteNumber(f));
    }```


Lots more information on <a href="http://www.sengpielaudio.com/calculator-notenames.htm">sengpiel audio</a>