-1
function onSuccess() {
var longest = "";
var listString = "";
var Count = 0;
var listEnumerator = listCollection.getEnumerator();
while (listEnumerator.moveNext()) {
    var currentItem = listEnumerator.get_current(),
        title = currentItem.get_title();

    listString += "<br>" + title;

    if (longest.length < title.length)
        longest = title;
    Count = Count + 1;
}

need to know how i get the count of items in the longest name of a list. this function help me to find the list who have the longest name but i dont get the count.

  • 1
    did you try with count++; ? Count +=1; – Waqas Sarwar MVP Jun 3 '15 at 17:22
  • Not working :/ I need to connect the count to this list i get when i run the whele loop – Melad Francis Jun 3 '15 at 18:13
  • what you need, you want the count the number of longest title? what is the output of the counte( i mean what number it return? – Waqas Sarwar MVP Jun 3 '15 at 18:16
  • it returen 1 or 32 – Melad Francis Jun 3 '15 at 18:32
  • when its the right ansawer is 3 – Melad Francis Jun 3 '15 at 18:32
0

you need to put the if statement in "{}", to get the correct result. replace the part of code with below one.

if (longest.length < title.length){
        longest = title;
    Count = Count + 1;}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.