forked from Zelechos/Pragmatic_JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise16.js
More file actions
20 lines (17 loc) · 755 Bytes
/
Copy pathExercise16.js
File metadata and controls
20 lines (17 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 16) Programa una función que cuente el número de caracteres de una cadena de texto, testeando el tipo de dato recibido pe. miFuncion("Hola Mundo") devolverá 10.
import validateString from "./validations.js";
'use strict'
const numberCharacters = data =>
(validateString(data))
?console.log(`el numero de caracteres de "${ data }" es : ${data.length}`)
:console.warn(`wrong parameter => parameter{${typeof(data)}} ,\n was expected => parameter{string}`)
// Testing
let text = new String("hola estoy programando en JS");
numberCharacters("ether");
numberCharacters(text);
numberCharacters([4,5.1]);
numberCharacters({});
numberCharacters(87);
numberCharacters('s');
numberCharacters("hola soy programador");
numberCharacters();