Just copy the code below and paste it in a “content editor” webpart on a web part page. SharePoint-2013-Hosting


It’s the working code. It will work 100% for you. I am using my SharePoint online account in this example. Just name the generic list in the text box you want to create then click on the Click me button as shown below.
A notification message will pop up as shown below.
You will find the newly created lists on the left navigation as shown below. If the list already exists it will give you a message saying that the list already exists.
It is a very basic example. I was looking for the working code but I was unable to find it anywhere, then after struggling with so many errors finally I was able to do that. I decided to post it  so new programmers can simply copy paste the code directly and understand it.