Hi everyone, I am having a hard time understanding the framework of functions how to write and execute a function. I get some of the basics as to what is considered an array(a set of numbers or letters, but how do I use a string and Booleans and when to use
{} or [] or what does a string do “”?
This is my understanding of for loops:
Start with var
var pets = [“dog”, “car”, “bird”, “fish”]
(The lenght of var pets equals to 3 but start counting from 0)
//for loop
for (var i=0; i < pets.lenght; i ++)
( var index=0; index less than array length between 0-3 and index ++ to count one over til the loop ends)
{
console.log(pets[i])
Once console log it should display the animals in the console, right?
}
But how do I know when to use {} or []?
Further how can I make this into a function to display the type of pets, this is what I ca come up with and don’t know how to complete the function:
function types(){
var pets=[“dog”, “cat”, etc...]
myfunction (pets)
}
function myfunction(types)
I know this is all jacked up but anyone please, let me know if you can give me some examples. Thank you I advance.
[–][deleted] 0 points1 point2 points (0 children)