소스 검색

Finish string-methods

Signed-off-by: Michael Tang <michael.h.tang@gmail.com>
Michael Tang 5 년 전
부모
커밋
a2cd1bb1ce
1개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 28 0
      string-methods.js

+ 28 - 0
string-methods.js

@@ -0,0 +1,28 @@
+let name = ' Andrew Mead  '
+
+// Length property
+console.log(name.length) 
+
+// Convert to uppercase
+console.log(name.toUpperCase())
+
+// Convert to lowercase
+console.log(name.toLowerCase())
+
+// Includes method
+let password = 'abc123password098'
+console.log(password.includes('password'))
+
+// Trim
+console.log(name.trim())
+
+// Challenge area
+
+// isValidPassword
+// length is more than 8 - and it doesn't contain the word password 
+let isValidPassword = function(pass) {
+    return pass.length > 8 && !pass.includes('password')
+}
+console.log(isValidPassword('asdfp'))
+console.log(isValidPassword('abc123!@##$%'))
+console.log(isValidPassword('asdfpasswordsdfdffdfdfd22'))