data struct_strings Flashcards
How can i extract the first word of an unknown str?
cl(berry.slice(0, berry.firstIndexOf(‘ ‘));
how can i extract the last word of an unknown str?
cl(berry.slice(lastIndexOf(‘ ‘)+ 1))
How can you berry up the last index of a str?
const berry = str.slice( -1 )
I have a string of words that are all lowercase. I wanna print them with the first letters capped. How can i do this with a func?
create a func. with a param (refers to input string).
2. make a berry with param.split( ‘ ‘)
3. berry up an empty array to store results.
4. for ( i of PBS )
{ emptyArray.push( [ i ].toUpperCase( ) + i.slice( 1 ) }
5. return emptyArray.join( ‘ ‘)
a ragged undercored_str which must be turned to camelCase.
I wanna convert an arbitrary number of under scored string names into camel case names. The input is a single ragged string with the names separated by a \n. How can I do this?
- set up a func. 2. create a BERRY that splits(‘ _’).
- now that Ive split the text into arrays/rows. set up a for loop: for i in BERRY
- Clean up/berry up the 2 items in each array:
const [ first, second ] = counter.toLowerCase( ).trim( ).split( ‘_’); - berry up a template literal statement: const output =
${first}${second.relace(second[ 0 ], second[0].toUpperCase( ) )}
How can I call the last position of a duplicate string item?
CL(berry.lastIndexOf(‘ x ‘)
const leper = 'whamBamThankYou'; CL(leper.slice( 6 )
what does this print?
mThankyou
java slices everything before the given index number.
refering to the start and stop args of the slice method.
stop specifically. If the value is 7, is the value at index 7 eliminated?
No, the slice ends at 6.
const herper = 'lesionsInSeasons' CL(herper.slice( -2)) what does this prnt?
ns
A drunk user entered his name like this: ‘jOnaS.
Describe line by line, the func. that can clean it up.
const correctName = function (spelly) { const spellyLower = spelly.toLowerCase(); const spellyCorrect = spellyLower[0].toUpperCase() + spellyLower.slice(1); console.log(spellyCorrect); };
correctName(‘hfjhjYYYY’);
drunk user email entry: ‘ geIIoY@gMail.com \n
clean it up in one berry.
const cleanEmail = berry.toLowerCase().trim()
I can double up the same method on a berry:
TRUE OR FALSE?
TRUE: let price = '288,88E' let canprice = price.replace( ' E', '$').replace(' , ', ' .' )
How can i replace all occurences of a word in a string?
CL(berry.replace( /word/g, ‘ newWord’ )
There are 3 boolean methods we can use with strs. What are they?
berry. includes(‘x’)
berry. startsWith(‘x ‘)
berry. endsWith(‘x ‘)
What does this prnt?
CL(‘Danny Abubakar Asema’.split(‘ ‘);
[‘Danny’, ‘Abubakar’, ‘Asema’]