Need help translating C# to JavaScript.

Hi there,

Today I have been trying to translate a C# inventory system into JavaScript. I just got stuck on a problem I don’t know the answer to.

The following code is written in my C# script:

//Display a tooltip for the specific item
	string CreateTooltip(Item item)
	{
		tooltip = "<color=#4DA4BF>" + item.itemName + "</color>

" + “<color=#f2f2f2>” + item.itemDesc + “”;
return tooltip;
}

My guess on getting this to work in JavaScript was the following:

String CreateTooltip()
{
	//To Do
}

But unity pops up with an error telling me ‘String’ is not a valid macro. So my question is how would I do that the right way in JavaScript?

I am quite new to unity so I am sorry if the answer is obvious…

Try this:

function CreateTooltip(item : Item) : String {

You declare type after the function or variable in Javascript/Unityscript.