How's my pig latin

As I personally don’t know any programmers or devs, may I ask the good people of this forum to check out my algorithm and let me know what you think, It works, and I know there’s a one liner somewhere out there for this, but is mine looking anything like a pro would write? Even a bit of it?

I did some googling for this, the logic is mine - some of the syntax and the test method was looked up as I worked.

If this is now in the wrong forum - mods, feel free to move.


function translatePigLatin(str) {
    	if(/[aeiou]/.test(str[0]) === true){
    	str = str + "way";
    		while (/[aeiou]/.test(str[0]) === false){
    			str = str.split("");
    			var letter = str.shift();
    			str = str.join("");
    			 str = str + "ay";
    	return str;

repl, commented[/spoiler]

I like your logic there. another one of those obvious in hindsight solutions you always seem to have. A bit simpler than mine which as you say, translates into less overhead.

I’ll go and have a play with slice. I’ve used it before so probably should have thought of it this time - or maybe i’ll leave it a couple of weeks to forget your solution first :slight_smile: