data struct_strings Flashcards

1
Q

How can i extract the first word of an unknown str?

A

cl(berry.slice(0, berry.firstIndexOf(‘ ‘));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how can i extract the last word of an unknown str?

A

cl(berry.slice(lastIndexOf(‘ ‘)+ 1))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you berry up the last index of a str?

A

const berry = str.slice( -1 )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

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( ‘ ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?

A
  1. set up a func. 2. create a BERRY that splits(‘ _’).
  2. now that Ive split the text into arrays/rows. set up a for loop: for i in BERRY
  3. Clean up/berry up the 2 items in each array:
    const [ first, second ] = counter.toLowerCase( ).trim( ).split( ‘_’);
  4. berry up a template literal statement: const output = ${first}${second.relace(second[ 0 ], second[0].toUpperCase( ) )}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can I call the last position of a duplicate string item?

A

CL(berry.lastIndexOf(‘ x ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
const leper = 'whamBamThankYou';
CL(leper.slice( 6 )

what does this print?

A

mThankyou

java slices everything before the given index number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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?

A

No, the slice ends at 6.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
const herper = 'lesionsInSeasons'
CL(herper.slice( -2))  what does this prnt?
A

ns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A drunk user entered his name like this: ‘jOnaS.

Describe line by line, the func. that can clean it up.

A
const correctName = function (spelly) {
  const spellyLower = spelly.toLowerCase();
  const spellyCorrect = spellyLower[0].toUpperCase() + spellyLower.slice(1);
  console.log(spellyCorrect);
};

correctName(‘hfjhjYYYY’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

drunk user email entry: ‘ geIIoY@gMail.com \n

clean it up in one berry.

A

const cleanEmail = berry.toLowerCase().trim()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

I can double up the same method on a berry:

TRUE OR FALSE?

A
TRUE:
let price = '288,88E'
let canprice = price.replace( ' E', '$').replace(' , ', ' .' )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can i replace all occurences of a word in a string?

A

CL(berry.replace( /word/g, ‘ newWord’ )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

There are 3 boolean methods we can use with strs. What are they?

A

berry. includes(‘x’)
berry. startsWith(‘x ‘)
berry. endsWith(‘x ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does this prnt?

CL(‘Danny Abubakar Asema’.split(‘ ‘);

A

[‘Danny’, ‘Abubakar’, ‘Asema’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can i split and berry up my name at the same time?

A

const [first, last] = ‘Daniel Tucket ‘.split(‘ ‘)

17
Q

How can I prnt my berried fist and last names along with a ‘Mr.’ string? (No template literal):

A

let myName = [‘Mr.’ , first , last].join( ‘ ‘)

prnts: Mr. Daniel Tucket

18
Q

describe a func. that would print a multiple word string given in lowercase, converted with the first letters of each word capped?

A
const getName = function (wretchedname) {
  const wretchedSplit = wretchedname.split(' ');
  const holder = [];
  for (const i of wretchedSplit) {
    holder.push(i[0].toUpperCase() + i.slice(1));
  }
  return holder.join(' ');
};
19
Q

Give an example of padStart and PadEnd in one statement.

A

const padMe = berry.padStart(20, ‘ @ ‘).padEnd( 35, ‘ # ‘)

20
Q

Please decribe the func. to mask a credit card number.

A
const hideNums = function (number) {
  const convertStr = number + '';
  const exposed = convertStr.slice(-4);
  return exposed.padStart(convertStr.length, 'x');
};
21
Q

repeat a str 10 times please.

A
const msg = 'ready when you are';
CL(msg.repeat(10 ))
22
Q

How can I func. an html ‘button’?

  1. How can I berryup an html text input value?
A
  1. document.querySelector(‘button’).addEventListener(‘click’, function () {
  2. const text = document.querySelector(‘textarea’).value;
23
Q

How can i use a for loop to loop an element as well as the index of said element at once?

A

for ( const [ i , el ] of berry.ENTRIES( ) )