This is the first time I am using Underscore.js. I have included the production underscore-min.js at the bottom of my page ( which is in Jade originally ), just before my custom script.
<script src="/javascripts/underscore-min.js">
<script src="/javascripts/custom.js">
Now, I call this function in my custom.js:
var selections = "Bold;Business-like;Charming";
var num_selections = _str.words( question.selected_words, ";").length;
Basically, I need to know the number of words selected and the native javascript method split returns 1 for even a blank string. But when I use this code, I get this error in my browser console:
Uncaught ReferenceError: _str is not defined
I tried using this line before using _str, but then I get require is not defined:
var _ = require('underscore');
Or, perhaps I can put my question as How do we start using underscore functions in our front-end javascripts?
_strfunction in my front-end javascript.