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 */
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.