-
Notifications
You must be signed in to change notification settings - Fork 0
Class4 piglatin #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
8012371
37c1336
a4ca50d
74cf90c
d26a7a1
590209f
f3c25c3
ded212b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,14 @@ | ||
| 'use strict'; | ||
|
|
||
| //global storage | ||
| //const pigLatinStr = ('choose your word here') => {} | ||
| //const vowels = ('aeiou') | ||
|
|
||
| //function names, purpose, method | ||
| //convert your word to lower case, toLowerCase method | ||
| //get rid of any empty space, trim method, chained to toLowerCase | ||
| //vowelIndex(), use this inside of a forEach method to find the index of the vowels in the word, indexOf method | ||
|
|
||
| const assert = require('assert'); | ||
| const readline = require('readline'); | ||
| const rl = readline.createInterface({ | ||
|
|
@@ -8,11 +17,29 @@ const rl = readline.createInterface({ | |
| }); | ||
|
|
||
|
|
||
| function pigLatin(word) { | ||
| const pigLatin=(word)=> { | ||
| word.toLowerCase().trim(); | ||
| const wordArr=word.split(); | ||
| const vowel = ['a', 'e', 'i', 'o', 'u'] | ||
| wordArr.forEach((letter, i) => { | ||
| if(vowel.indexOf(letter)!==-1){ | ||
| return vowel; | ||
| } | ||
| }); | ||
| //slice, indexOf, concat | ||
| //checkFirstVowel goes here!!! | ||
| let firstVowel; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this being used? why is it declared here? |
||
| vowel.forEach=()=> | ||
| word.copyWithin(searchVowel[0], ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be same line as 32 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does the method copyWithin do? |
||
| //moveToEnd(), move consonants before the first vowel to the end of the word, | ||
| word.push(`ay`); | ||
| word.join(``); | ||
| return word; | ||
| } | ||
|
|
||
| pigLatin(`scram`); | ||
|
|
||
| // Your code here | ||
|
|
||
| } | ||
|
|
||
|
|
||
| function getPrompt() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code should be indented 2 spaces for readability.