Giter VIP home page Giter VIP logo

phase-1-algorithms-palindrome's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phase-1-algorithms-palindrome's Issues

Workaround for the test

Canvas Link

https://learning.flatironschool.com/courses/6806/assignments/247610?module_item_id=584048

Concern

The student noticed that none of the failed test start and end with the same letter (Something like denied). They had returned true if the first and last letter were true instead of continuing to check and thus ran into issues where all the test passed although their solution wasn't correct. I think adding an example of this case (a non palindrome with a first and last letter being similar) could be a good idea to hound in the idea of scoping and where returns lie

Additional Context

No response

Suggested Changes

Adding more test to fix these workarounds

Submission is correct, but test deems it incorrect (even if using solution from next page)

Canvas Link

https://learning.flatironschool.com/courses/6190/assignments/225637?module_item_id=526926

Concern

When using test (and submitting the lab), the test deems my solution as not passing. However, when using the words provided from the lab, the return result is what was expected (true or false)

Furthermore, on next page which contains the solution, that solution is considered incorrect as well per this labs test.

I can't submit this lab until the test code is corrected

my code

function isPalindrome (word){
const wordArray = [...word]
const ansArray = []

for (let i = wordArray.length -1; i >= 0; i--){
    ansArray.push(wordArray[i])
}

for (let i = wordArray.length -1; i>=0; i--){
    if (ansArray[i] !== wordArray[i]){
        return false;
    }

}
return true
}

and the solution, which your own tests show it's incorrect.

function reverseString(word) {
// create an array from the input string
const wordArray = word.split("");
// reverse the array
const reversedWordArray = wordArray.reverse();
// create a string from the reversed array
const reversedWord = reversedWordArray.join("");
// return the reversed string
return reversedWord;
}

function isPalindrome(word) {
// reverse the input string
const reversedWord = reverseString(word);
// if the reversed string is the same as the input
if (word === reversedWord) {
return true;
} else {
return false;
}
}

Additional Context

No response

Suggested Changes

fix the behavior of how test is testing code.

.map() issue

Canvas Link

https://learning.flatironschool.com/courses/6190/assignments/225637?module_item_id=526926

Concern

If you check out my code. When lines 5-10 are commented out. The palindromes always return false. Even though when you console.log them in the DOM you can see they equal each other. Then when I comment lines 5-10 back in to change the array back into a string I pass the tests. Its very strange because the code logic makes sense. A palindrome is a palindrome whether its in an array format or a string format. I'm thinking it might be because I used to the .map function? If you check this out could you send me a slack? I'm just kinda curious about it.

function isPalindrome(string) {
const arrayForward = string.split('')
const arrayBackward = []
arrayForward.map(letter => arrayBackward.unshift(letter))
// console.log(arrayForward)
// console.log(arrayBackward)
// const arrayForward2 = arrayForward.join('')
// const arrayBackward2 = arrayBackward.join('')
// console.log(arrayForward2)
// console.log(arrayBackward2)
if (arrayForward === arrayBackward) {
return true
console.log('true')
} else {
return false
console.log('false')
}
}

module.exports = isPalindrome;

Additional Context

I failed all the tests that should return true. Until I changed the array back into a string

Suggested Changes

Maybe its the .map() I used?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.