Skip to content
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

Reto #47 #1118

Open
dquirosd101 opened this issue Nov 29, 2022 · 0 comments
Open

Reto #47 #1118

dquirosd101 opened this issue Nov 29, 2022 · 0 comments

Comments

@dquirosd101
Copy link

var _str = ".-Aá?aaaBbEeeweIiiOoU:";
var _arr = [0,0,0,0,0];
//a e i o u

Array.from(_str, (x) => {

if(x.trimEnd().length >0)

   _value = x.toUpperCase();

   _value = _value == 'Á' ? _value.replace('Á','A'): 
  _value == 'É' ? _value.replace('É','E'):
  _value == 'Í' ? _value.replace('Í','I'):
  _value == 'Ó' ? _value.replace('Ó','O'):
  _value == 'Ú' ? _value.replace('Ú','U'): _value;

  switch(_value) {
  case 'A':
    _arr[0] = Number(_arr[0]) + 1;
    break;
  case 'E':
    _arr[1] = Number(_arr[1]) + 1;
      break;
  case 'I':
    _arr[2] = Number(_arr[2]) + 1;
      break;
  case 'O':
    _arr[3] = Number(_arr[3]) + 1;
      break;
  case 'U':
    _arr[4] = Number(_arr[4]) + 1;
      break;
    default:
      // code block
 }

});

var _value = Math.max(..._arr);

if (!Number.isNaN(_value) && Number(_value)>0) {
var _posision =_arr.indexOf(_value)

var _vocal = _posision == 0 ? 'VOCAL MÁS COMÚN ES A':
_posision == 1 ? 'VOCAL MÁS COMÚN ES E':
_posision == 2 ? 'VOCAL MÁS COMÚN ES I':
_posision == 3 ? 'VOCAL MÁS COMÚN ES O':
_posision == 4 ? 'VOCAL MÁS COMÚN ES U': 'No se encontraron vocales';
console.log(_vocal);
}else{

console.log('No se encontraron vocales');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant