Search code examples
jqueryglobal-variables

How to create a global variable in jQuery


I am a student and I am currently learning jQuery.

Create a toDos global variable holding three to do items, wake up, eat breakfast, and code.

I figured I need to make a global variable of type array which holds the three items, but I have no idea how to write this in jQuery, any tips ?


Solution

  • jQuery library is build from JavaScript. Here is how to create global variable in JavaScript.

    var data = ["wake up","eat breakfast","code"];
    
    alert(data[0]);  // will display "wake up"