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

aziza-yesim-array-class5 #165

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions class-5-js-array/aziza-yesim/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
</body>
</html>
40 changes: 40 additions & 0 deletions class-5-js-array/aziza-yesim/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Challenge 1
let swapCase = function(letters){
let newLetters = "";
for(let i = 0; i<letters.length; i++){
if(letters[i] === letters[i].toLowerCase()){
newLetters += letters[i].toUpperCase();
}
else {
newLetters += letters[i].toLowerCase();
}
}
console.log(newLetters);
return newLetters;
}
let text = 'Thank You';
let swappedText = swapCase(text);



// Challange 2
function users (users){
let chatroomStatus = users.length;
if (chatroomStatus == 0){
console.log("no one online");
}
else if (chatroomStatus == 1) {
console.log(users[0] + " online");
}
else if (chatroomStatus == 2) {
console.log(users[0] + " and " + users[1] + " online.");
}
else {
console.log(users[0] + ", " + users[1] + " and " + (chatroomStatus-2) + " more online.");
}
}
users("");
users(["Liz"]);
users(["Liz", "Ammar"]);
users(["Liz", "Hakan", "Ammar", "Feras", "Jaime", "Derya"]);
console.log("---------------------------------------------------");
58 changes: 58 additions & 0 deletions class-5-js-array/aziza-yesim/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Instructions For The Exercise

Reverse the Case
Given a string, in the console create a function to reverse the case. All lower-cased letters should be upper-cased, and vice versa.


Notes:


If you get stuck on a challenge please search it online and try to find resources
If you are really stuck, please ask your Instructors.

Examples:

reverseCase("Happy Birthday") ➞ "hAPPY bIRTHDAY"

reverseCase("MANY THANKS") ➞ "many thanks"

reverseCase("sPoNtAnEoUs") ➞ "SpOnTaNeOuS"


********


Instructions For The Exercise

Chat Room Status
In the console, write a function that returns the number of users in a chatroom based on the following rules:

If there is no one, return "no one online".
If there 1 person, return "[user1] online".
If there are 2 people, return [user 1] and [user 2] online".
If there are n>2 people, return the first two names and add "and n-2 more online".

For example, if there are 5 users, return:

"[user1], [user2] and 3 more online"

Notes:


If you get stuck on a challenge please search it online and try to find resources
If you are really stuck, please ask your Instructors.


Examples:

chatroomStatus([]) ➞ "no one online"

chatroomStatus(["Liz"]) ➞ "Liz online"

chatroomStatus(["Liz", "Ammar"]) ➞ "Liz and Ammar online"

chatroomStatus(["Liz", "Hakan", "Ammar", "Feras", "Jaime", "Derya"])
➞ "Liz, Hakan and 4 more online"


[1,1,2,2,3,4,3,5] -> [1,2,3,4,5]