My code runs fine, but I have no idea why JSLint (running on Brackets text editor) keeps telling me: 'numeral' was used before it was defined
I am using Numeral.js to display numbers with commas. Below is the code I am using.
$("input[name='service']").click(function () {
var a = parseInt($("#product-one input:checked").val(), 10),
b = parseInt($("#product-two input:checked").val(), 10),
c = parseInt($("#product-three input:checked").val(), 10),
total = numeral(a + b + c).format('0,0');
$(".number").text('$' + total);
});
I ran into similar problems before when I started learning JQuery a few months ago. It kept telling me $ and alert were undefined, but after some digging around I figured I had to put this on top of my JS file:
/global $, JQuery/
and
/jslint devel: true/
Is there a similar fix for this?
This is the same problem you had before; you are correct. Simply add numeral
to the list of global variables you want your linter to recognize, and it should leave them alone:
/* global $, JQuery, numeral */