Inbar Azulay Inbar Azulay - 11 days ago 6
Javascript Question

Replace part of string with variable



I have the following string:

documentation/:docsID/items


Now I want to replace the
:docsID
by a variable.

So if the variable is equal to
12
, i want the link look like
documentation/12/items
.
How can I accomplish this with Javascript?

Answer
string.replace(":docsID",var)

To easy right? Next time try first!

Comments