Skip to content

Commit

Permalink
Added check for no input and 0 input (#261)
Browse files Browse the repository at this point in the history
Issue Link: #204

Accidentally committed codes of two different issues to this PR. I have
submitted another PR for the other
issue(#197).
Please accept both. Thank You

Please go through all the Screenshots. 


![image](https://github.com/Git21221/JS-beginner-projects/assets/69238138/5ce0e81c-6ee1-4384-bb23-9a79e073add4)

![image](https://github.com/Git21221/JS-beginner-projects/assets/69238138/a85c9639-062f-4503-81ad-bb5081fb666d)

![image](https://github.com/Git21221/JS-beginner-projects/assets/69238138/c79ac9df-ba65-415b-b30c-b0e01ec82f1d)
  • Loading branch information
Git21221 authored Oct 4, 2023
2 parents 45fc7af + 5a2eae1 commit 02e0aac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
37 changes: 25 additions & 12 deletions GitHub Card/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,34 @@ const usernameInput = document.querySelector("#username");



async function profile(name="shouryasinghrathore") {

let quotes = await fetch(`https://api.github.com/users/${name}`)
let apiInfo = await quotes.json();
console.log(apiInfo)
image.setAttribute('src', apiInfo.avatar_url);
newname.innerHTML =apiInfo.login;
console.log(apiInfo.login)
following.innerHTML = apiInfo.following;
followers.innerHTML = apiInfo.followers;
id.innerHTML = apiInfo.id;

async function profile(name = "shouryasinghrathore") {
try {
let response = await fetch(`https://api.github.com/users/${name}`);

if (response.status === 404) {
profile();
document.getElementById("inputValue").value = "";
alert("Enter Valid Username");
} else if (response.ok) {
let apiInfo = await response.json();
console.log(apiInfo);
image.setAttribute('src', apiInfo.avatar_url);
newname.innerHTML = apiInfo.login;
console.log(apiInfo.login);
following.innerHTML = apiInfo.following;
followers.innerHTML = apiInfo.followers;
id.innerHTML = apiInfo.id;
} else {
console.error("Error fetching user data");
alert("Error fetching user data");
}
} catch (error) {
console.error("An error occurred:", error);
}
}



function processInput() {
let inputValue = document.getElementById("inputValue").value;
if (inputValue.trim() !== "") {
Expand Down
4 changes: 4 additions & 0 deletions Random Password Generator/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ document.addEventListener("DOMContentLoaded", function () {

function generatePassword() {
const length = parseInt(passwordLengthInput.value);
if(!length) {
alert("Please enter a valid password length.");
return;
}
const includeUppercase = includeUppercaseCheckbox.checked;
const includeLowercase = includeLowercaseCheckbox.checked;
const includeNumbers = includeNumbersCheckbox.checked;
Expand Down

0 comments on commit 02e0aac

Please sign in to comment.