layout: post title: Translating the provided string to pig latin date: 2017-11-02 —
Translating the provided string to pig latin.
This was challenging because i spent much onit trying to understand the problem and trying to think like how am i going to solve it.
Problem:
Create a function that wil translate pig latin, If words is consonant move it to the end of the word and suffixes an “ay”. also, If a word
begins with a vowel you just add “way” to the end.
my aPProach
In a given function i decided to have two variables for vowels and consonant so that i will be able compare them. I used str.match(vowels) to test whether my function will execute good results but it was returning unwanted results. So decided to change my test statement like instead of str.match(vowels) i used vowels.includes(str) to check whether an array includes a certain elements and if yes should return str by adding vocalic syllable, and cosonant.includes(str) to check whether an array includes a certain consonant_cluster if yes should return str.substr(2) to remove a the character and return new string and i added str.substring(0,2) to cut the first word and put it to the end of word adding vocalic syllable. It was working and returning an accurate results.
Problem stated:
When i consoled consonant_cluster it was suppose to slice the first and the second word and add the first word at the end of word but it sliced the first word only.
I decided to understand the problem and and think on how am i going to to solve it and i breaked it into pieces, and when something was not working as thought, I stoped and think on another solution.