forked from 7cordovac/Alex-name
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (55 loc) · 2.07 KB
/
script.js
File metadata and controls
72 lines (55 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//Create a sorting bin app that allows users to enter names. If the name starts //with “ A “ , it goes into list one. If the name has the word “Alex” anywhere //within the name, it goes in list “B”. If neither are true, it goes in list //“ C “ . (edited)*/
$(document).ready(function() {
$('button').click(function(){
var a = new RegExp('alex', 'ig');
var b = new RegExp('a', 'ig');
var name = $('#str1').val();
if(a.test(name)===true){
$('#alex_List').append('<h1>'+name+'</h1>');
}
else if(b.test(name)===true){
$('#a_List').append('<h1>'+name+'</h1>');
}
else{
$('#n_List').append('<h1>'+name+'</h1>');
}
})
// function checkName(str) {
// var input_name = str.toLowerCase();
// var result = /^alex/.test(input_name);
// if (result=== true){
// $("#alexList").append("<div>"+input_name+"</div>");
// } else
// if (input_name[0] === "a") {
// $("#aList").append("<div>"+input_name+"</div>");
// } else {
// $("#nList").append("<div>"+input_name+"</div>");
// }
// }
})
// THIS CODE TEST THAT LOGIC IS CORRECT IT DOES WORK
// function checkName(str) {
// var input_name = str.toLowerCase();
// var result = /^alex/.test(input_name);
// if (result=== true){
// console.log("alex is the name");
// } else
// if (input_name[0] === "a") {
// console.log("this is for A List")
// } else {
// console.log ("neither");
// }
// }
//checkName("Alex");
// if (input_name.search(/alex/ig) >= 0){
// alexList.append("input_name");
// $("#alexList").append("<div>"+str+"</div>");
// } else
// if (input_name.search(/a/ig) >= 0) {
// aList.append("input_name");
// $("#aList").append("<div>"+str+"</div>");
// } else {
// nList.append("input_name");
// $("#nList").append("<div>"+str+"</div>");
// }
// }