Skip to content

JavaScript solve - ali shakiba #59

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions math/111-999-two-digits-no-zero/JavaScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// i chose to solve this with string metod in js

// make counter
let counter = 0


const giveMeDigits = number => {
// creating set and turn my number to string

let mynumb = number.toString()
const mySet1 = new Set()

// loop on number and adding each elemet on it to my set
for (let i = 0; i < mynumb.length; i++) {
mySet1.add(mynumb[i])
}

// if size of my set equal to 2 mean => my number like this 122
// making with only two number
return mySet1.size == 2 ? true : false
}


// making loop for testing all number

for (let i = 100; i <= 999; i++) {

// in this line i check if i {my number from 100 to 999} have 0 inside that pass that i
if (i.toString().includes(0) == false) {
giveMeDigits(i) == true && (counter += 1)
}
}

console.log(counter)