Skip to content

Conversation

@pursuitMaddy
Copy link

No description provided.


function countNumbers(arr) {
let count = {}
for (let i = 0; i < arr.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using forEach here

Copy link
Author

@pursuitMaddy pursuitMaddy Jan 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it! seems like a longer code. Thank you

function isOdd() {

function isOdd(n) {
if (n % 2 === 1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just return the condition n % 2 === 1


function numberOfDigits(n) {
let num = n
return Math.floor(num.toString().length)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for Math.floor here. A string will always be an integer length and never a decimal

Copy link
Author

@pursuitMaddy pursuitMaddy Jan 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Thank you

function removeNumbersAtOddIndices() {
function removeNumbersAtOddIndices(arr) {
let output = [];
for (i = 0; i < arr.length; i += 2) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using filter here. But I do love your i += 2

let arr = str.split("")
let out = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i] !== "o" && arr[i] !== "e" && arr[i] !== "u" && arr[i] !== "i" && arr[i] !== "A" && arr[i] !== "E" && arr[i] !== "I" && arr[i] !== "U" && arr[i] !== "O" && arr[i] !== "a") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check out the includes method "aeiouAEIOU".includes(arr[i])

function removeVowels(str) {
let arr = str.split("")
let out = [];
for (let i = 0; i < arr.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try using a for of loop when going through strings and not needing the index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants