Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- return function (selector, count) {
- if(typeof selector === 'undefined' || selector === null || typeof selector !== 'string'){
- throw Error('Invalid or missing selector!');
- }
- if (isNaN(count) || count < 1) {
- throw Error('Count is not a valid number!');
- }
- var $ul = $('<ul />').addClass('items-list');
- var $selected = $(selector);
- if ($selected.length !== 0) {
- for (var i = 0; i < count; i += 1) {
- var $li = $('<li>')
- .addClass('list-item')
- .text('List item #' + i)
- .appendTo($ul);
- }
- $selected.append($ul);
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement