4 - Can someone explain me...I passed no.4 but I don`y understand why and how


This is my code
/*jshint multistr:true */
var text=("dabar", "dobar", "vidra", "Ana", "Nikola", "Ana");
var myName="Ana";
var hits=[]
for (var i=0; iif (text[i]==="A") {}

I passed...without any result in right window
Just to mention in exercises no.2 was written
"Declare and set the following three variables:
text, and make it a string containing some text. Place your name in there a couple of times!myName, and make it a string containing just your name.hits, and make it an empty array."

So I have written var text=[...].....etc, and pass no.2

I know if I write just text=("dabar", "dobar", "vidra", "Ana", "Nikola", "Ana") - without "var" in front of, code will work and result will be shown in right window "Ana", but what I don`t understantand is why should I write "text=" instead "var text=" where the exercise is to "Declare and set the following three variables"


To answer your question: because we need to do stuff with the text and so we save it in a var instead of just outputting it on the screen.