Can someone explain this to me i have no idea what str and " number" do here and how they function


so capitalize has (str) in it … i have no idea what that is… str is short for string
but in order for that to be a string it needs " "
but this is just (str) . i have no idea what its purpose is there since it doesn’t actually say that its a str ,theres no var str = ""
that defines that short term for a string so im really confused what its doing there.

I understand for example var city =“paris” thats a string
i somewhat understand that when you put var capital = capitalize(city), im guessing it wants function capitalize and var city
to change the var city that is, they want it to have the first letter capitalized . but what purpose does the (str) at the begining have to do with it… couldnt that capitalize() be empty and still work?

And this!!! This blows my mind , what in gods name does "number " mean here … correct me if i’m wrong but even though it says number if its in " " it makes it a string . in my eyes str === “number” . str isnt a string and “number” isnt a number. does the "number " mean something in js ? bcs to me THAT looks like a string .


this examples assume you have a console where you can see the output, if you don’t, use jsbin, console.log() will log the output to the console

i think first and for most its important to understand function parameter concept, lets create a function with parameter x:

// function with parameter x
function example(x){

// function calls with arguments for parameter
example("hello world")
example("parameters vs arguments")

see comments in code, the arguments at function get passed into the function parameter (x), so now x contains a string, if you like you can think that JS does this under the hood when function is called with argument "hello world":

x="hello world"

now i hope you understand why str contains a string ("paris")

typeof is a built in function that returns a string with the data of str

we can see this:

function capitalize(str){
    console.log(typeof str)


see how typeof returns the data type as string? So if we check for a certain data type, we can just check if typeof str equals a certain datatype

37 is of data type number, so typeof returns "number" which allows us to check if 37 is a number


w8 so is “number” also built in function ?


no, number is a data type:

there are different data types in JS (and other programming language), understanding data-types is fundamental

the typeof function is a function to determine the typo of object (pretty big clue in the name of typeof function :wink: )


darn thanks for the info . i cant even tell the difference between arrys or data type or …well yeah it seems it blew up in my face


well, understanding the data types is fundamental, otherwise you won’t understand typeof

There is plenty of documentation and tutorials on data types, i am sure you can find them :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.