Check for letters in a string | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Check for letters in a string

i want to make a program that does something like this: input (name) Roel the program has to write every sign that is checked very fast (almost like bruteforce pw crackers) and if the R is seen, break it so it will look like this a b c d e f g h i j k l m n o p q r ra rb rc rd re rf rg rh ri rj rk rl rm rn ro roa rob roc rod roe roea roeb roec roed roee roef roeg roeh roei roej roek roel something like that

8th May 2018, 8:44 PM
Roel
Roel - avatar
12 Antworten
+ 3
var name = prompt('Input a name:',).toLowerCase (); document.write('<p id="holder"></p>'); var holder = document.getElementById('holder'); var found = ''; var nameIndex=0; var letters = "abcdefghijklmnopqrstuvwxyz"; var i=0; var loop=setInterval(function(){ holder.innerHTML=found+letters[i]; if(letters[i++]===name[nameIndex]){ found+=letters[--i]; i=0; nameIndex++; if(name===found)clearInterval(loop); } },200);
8th May 2018, 10:05 PM
Nommer101
Nommer101 - avatar
+ 3
Roel I'm more than happy to help you anytime you want help. So you want one line with the first character changing until it finds the right character then the the next character starts searching?
8th May 2018, 9:51 PM
Nommer101
Nommer101 - avatar
+ 2
var name = prompt('Input a name:',).toLowerCase (); var found = ''; var nameIndex=0; var letters="abcdefghijklmnopqrstuvwxyz"; for(var i=0;i<letters.length;i++){ document.write(found+letters[i]+'<BR>') if(letters[i]===name[nameIndex]){ found+=letters[i]; i=-1; nameIndex++; if(found===name)break; } }
8th May 2018, 9:19 PM
Nommer101
Nommer101 - avatar
+ 2
Roel If you want to collaborate and work on a project together then just let me know. I'm fairly busy thou and I'll probably frustrate you because I will make you fix your mistakes but I think it would be fun... for me at least. :)
8th May 2018, 10:08 PM
Nommer101
Nommer101 - avatar
+ 2
Roel Sorry its a bit messy but I didn't have any context to work with else I would make it a bit more dynamic. If you nee help understanding parts or why I did something just ask me.
8th May 2018, 10:10 PM
Nommer101
Nommer101 - avatar
+ 1
Roel https://code.sololearn.com/W9V4snnORovB/?ref=app I can teach you. I'm busy with this.
8th May 2018, 10:13 PM
Nommer101
Nommer101 - avatar
0
Dmitriy it only outputs a's for me, whatever i try -add letters -make it an array -write more for loops
8th May 2018, 9:17 PM
Roel
Roel - avatar
0
Nommer101 thanks a lot, and maybe its a bit too much asked but how can i delete the not found letters, so it stays on just one line (usefull when entering long names)
8th May 2018, 9:48 PM
Roel
Roel - avatar
0
yes (if its possible and not too much asked of you)
8th May 2018, 9:52 PM
Roel
Roel - avatar
0
Nommer101 sounds fun, I'll let you know, the only problem is that I'm not sure if I can come up with some project, but I can try start one, and I'll let you know when I will start
8th May 2018, 10:11 PM
Roel
Roel - avatar
0
Nommer101 the problem is not that I don't understand it, the problem is that I can't come up with codes like that
8th May 2018, 10:12 PM
Roel
Roel - avatar
0
Nommer101 wow, nice code already
8th May 2018, 10:15 PM
Roel
Roel - avatar