Good day.

I have such a problem, I can not connect (glue) the elements of the array into one line, here is the code:

function rt() { var first = []; // создаСм массив символов var stroka = ""; // создаСм ΠΊΠΎΠ½Π΅Ρ‡Π½ΡƒΡŽ строку $('.sch').append($(this).val()); // послС класса Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ Π½Π° экран ΠΏΠΎ 1 символу first[l] = $(this).val(); // заносим ΠΊΠ°ΠΆΠ΄Ρ‹ΠΉ символ Π² массив stroka += '' + first[l] + ''; // Ρ‚Π΅ΠΏΠ΅Ρ€ΡŒ Π½Π°Π΄ΠΎ ΡΠΎΡΡ‚Π°Π²ΠΈΡ‚ΡŒ ΠΎΠ΄Π½Ρƒ строку символов l++; // ΡƒΠ²Π΅Π»ΠΈΡ‡ΠΈΠ²Π°Π΅ΠΌ индСкс массива alert(stroka); // Π²Ρ‹Π΄Π°Ρ‡Π° для ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ, **Π²Ρ‹Π΄Π°Π΅Ρ‚ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ послСдний символ** return stroka; // Π½Ρƒ ΠΈ Π²ΠΎΠ·Π²Ρ€Π°Ρ‚ } 

Help me please. :)

  • four
    odd odd code ['h', 'e', ​​'l', 'l', 'o', ',', '', 'w', 'o', 'r', 'l', 'd' ] .join (""); - join - Specter
  • 2
    Well, or cycle. join of course yes, in short) - Shevsky
  • Well this is for my case it should be so) - Bob Marley
  • 2
    Does your case necessarily require an Indocode? - Specter
  • one
    You have described the task in a completely different way that your code "must perform" it. - Blah blah blah, I need to output on alert the sum of the first and second digits from the minutes of the current date, I have the code, but for some reason it returns an incorrect value: alert (((minute [1] + minute [2] ) / sqrt (hour * rand (1, 5)) + (rand (1, 2) == 1? 10: sqr (rand (10, 50)))); - Why does it divide by an hour multiplied by a random number and a bunch of strange operations? - For my case it is necessary. - Shevsky

2 answers 2

Hmmm .. A lot of things will remain a mystery to me, but, although I’m not a telepath, I’ll still try)) Look at this example , it may be useful.

    You probably just need to initialize the variable l. If you look at this example , you can see that without initialization, l always NaN or undifended which leads to writing in first[NaN] .

    although in your case there is some discrepancy between the code and the question as well as the array - why is it needed at all? Your code is similar to this:

     function rt() { var chren = ""+$(this).val()+""; $('.sch').append(chren); // добавляСм Ρ…Ρ€Π΅Π½ΡŒ Π² ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Ρ‹ с классом .sch alert(chren); // Π²Ρ‹Π΄Π°Ρ‡Π° для ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ, **Π²Ρ‹Π΄Π°Π΅Ρ‚ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ послСдний символ** return chren; // Π½Ρƒ ΠΈ Π²ΠΎΠ·Π²Ρ€Π°Ρ‚ } 
    • one
      @denisKlimenko, as part of the question, edit it so that it clearly describes your task and your difficulties. I doubt that you want to pay me my time, communicating not within the framework of the hashcode :-) - Chad
    • Uncle - Khokhol? It can be seen :-) - Chad